]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Speedup parsing of functions.
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 11 Aug 2017 11:44:32 +0000 (13:44 +0200)
committerPaul Smith <psmith@gnu.org>
Sat, 11 Nov 2017 15:08:30 +0000 (10:08 -0500)
Use the stopchar map to quickly jump over everything that is
not an open/close brace, an open/close parenthesis or a comma.

This saves 1% on QEMU's noop build (from 11.23s to 11.1s).

* function.c (find_next_argument, handle_function): Check
with STOP_SET before comparing against individual characters.
* main.c (initialize_stopchar_map): Initialize MAP_VARSEP
mappings in stopchar_map.
* makeint.h (MAP_VARSEP): New.

function.c
main.c
makeint.h

index edfacdf1b01abc580e474a37d863b2b28ce73343..a22352ff120117ab6e49326e9c9d9e8b8a9559d3 100644 (file)
@@ -329,7 +329,10 @@ find_next_argument (char startparen, char endparen,
   int count = 0;
 
   for (; ptr < end; ++ptr)
-    if (*ptr == startparen)
+    if (!STOP_SET (*ptr, MAP_VARSEP|MAP_COMMA))
+      continue;
+
+    else if (*ptr == startparen)
       ++count;
 
     else if (*ptr == endparen)
@@ -2458,7 +2461,9 @@ handle_function (char **op, const char **stringp)
      count might be high, but it'll never be low.  */
 
   for (nargs=1, end=beg; *end != '\0'; ++end)
-    if (*end == ',')
+    if (!STOP_SET (*end, MAP_VARSEP|MAP_COMMA))
+      continue;
+    else if (*end == ',')
       ++nargs;
     else if (*end == openparen)
       ++count;
diff --git a/main.c b/main.c
index 5e0b7aa6211f8b26c6f349e519c67fa66abbce78..9fa2c840ce7c8f76af5d56af1d38ddda54201828 100644 (file)
--- a/main.c
+++ b/main.c
@@ -635,6 +635,10 @@ initialize_stopchar_map (void)
   stopchar_map[(int)'|'] = MAP_PIPE;
   stopchar_map[(int)'.'] = MAP_DOT | MAP_USERFUNC;
   stopchar_map[(int)','] = MAP_COMMA;
+  stopchar_map[(int)'('] = MAP_VARSEP;
+  stopchar_map[(int)'{'] = MAP_VARSEP;
+  stopchar_map[(int)'}'] = MAP_VARSEP;
+  stopchar_map[(int)')'] = MAP_VARSEP;
   stopchar_map[(int)'$'] = MAP_VARIABLE;
 
   stopchar_map[(int)'-'] = MAP_USERFUNC;
index d71c043e68cd2e87eaf22e62e01de14f40cc2eff..2adab63b2c74a8cf634305e4e64baff03c936a52 100644 (file)
--- a/makeint.h
+++ b/makeint.h
@@ -397,6 +397,7 @@ extern int unixy_shell;
 #define MAP_SEMI        0x0010
 #define MAP_EQUALS      0x0020
 #define MAP_COLON       0x0040
+#define MAP_VARSEP      0x0080
 #define MAP_PIPE        0x0100
 #define MAP_DOT         0x0200
 #define MAP_COMMA       0x0400