speed up input parsing

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.m4.patches
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

While working on argv_ref patch 29, I noticed that the master branch had a
variable input_change which was always true.  This has been the case ever
since it was introduced in commit 3883a on 2006-10-25; even though that
patch was copied from the branch where the variable is properly cleared.
This one-liner patch gives about a 5% speedup to running autoconf on
coreutils.  Master is still about 50% slower than branch-1.6 because of
its heavy use of indirect function calls, although I'm hoping that porting
argv_ref patch 29 will improve the situation.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             [email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmVcSEACgkQ84KuGfSFAYAFCwCbB6hKDaQ1aoCj5XcbAnYe08w+
bSsAn2FySqufKA6D+f9PEMCRz5O5xzkR
=kynk
-----END PGP SIGNATURE-----

_______________________________________________
M4-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch397 (text/plain, 1.5 KB)
From efb88298e6f6933335f9cdfb1d96753271052efb Mon Sep 17 00:00:00 2001
From: Eric Blake <[email protected]>
Date: Fri, 13 Feb 2009 06:02:22 -0700
Subject: [PATCH] Speed up parsing when detecting input file change.

* m4/input.c (next_char): Clear input_change flag.  Bug introduced
2006-10-25.

Signed-off-by: Eric Blake <[email protected]>
---
 ChangeLog  |    6 ++++++
 m4/input.c |    5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a0802ed..6717a8a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-02-13  Eric Blake  <[email protected]>
+
+	Speed up parsing when detecting input file change.
+	* m4/input.c (next_char): Clear input_change flag.  Bug introduced
+	2006-10-25.
+
 2009-02-12  Eric Blake  <[email protected]>

 	Avoid quadratic code when walking definition stack.
diff --git a/m4/input.c b/m4/input.c
index c3c47d0..2672386 100644
--- a/m4/input.c
+++ b/m4/input.c
@@ -1,6 +1,6 @@
 /* GNU m4 -- A simple macro processor
-   Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2006, 2007, 2008
-   Free Software Foundation, Inc.
+   Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2006, 2007, 2008,
+   2009 Free Software Foundation, Inc.

    This file is part of GNU M4.

@@ -1287,6 +1287,7 @@ next_char (m4 *context, bool allow_quote, bool allow_argv, bool allow_unget)
 	{
 	  m4_set_current_file (context, isp->file);
 	  m4_set_current_line (context, isp->line);
+	  input_change = false;
 	}

       assert (isp->funcs->read_func);
-- 
1.6.1.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.