cppmacro.c (_cpp_create_definition): Optimize the case of a macro defined to itself.
authorNeil Booth <neilb@earthling.net>
Sun, 29 Oct 2000 11:37:18 +0000 (11:37 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sun, 29 Oct 2000 11:37:18 +0000 (11:37 +0000)
* cppmacro.c (_cpp_create_definition): Optimize the case of
        a macro defined to itself.

From-SVN: r37123

gcc/ChangeLog
gcc/cppmacro.c

index 2172a8e272afd7f143d454143b817a0a725ffd77..af210008cbe8ec11bc934c37f78592a2d64d578c 100644 (file)
@@ -1,3 +1,8 @@
+2000-10-29  Neil Booth  <neilb@earthling.net>
+
+       * cppmacro.c (_cpp_create_definition): Optimize the case of
+        a macro defined to itself.
+
 2000-10-29  Neil Booth  <neilb@earthling.net>
 
        * cpplex.c (save_comment): Don't store new lines in C++ comments.
index 58d3020797c4003b9f3a3233d15db8e2a03be369..35e66f48054049e06038f357e66f3478e0f56260 100644 (file)
@@ -1403,7 +1403,6 @@ _cpp_create_definition (pfile, node)
   macro->paramc = 0;
   macro->fun_like = 0;
   macro->var_args = 0;
-  macro->disabled = 0;
   macro->count = 0;
   macro->expansion = (cpp_token *) POOL_FRONT (&pfile->macro_pool);
 
@@ -1485,6 +1484,11 @@ _cpp_create_definition (pfile, node)
   /* Clear the whitespace flag from the leading token.  */
   macro->expansion[0].flags &= ~PREV_WHITE;
 
+  /* Implement the macro-defined-to-itself optimisation.  */
+  macro->disabled = (macro->count == 1 && !macro->fun_like
+                    && macro->expansion[0].type == CPP_NAME
+                    && macro->expansion[0].val.node == node);
+
   /* Commit the memory.  */
   POOL_COMMIT (&pfile->macro_pool, macro->count * sizeof (cpp_token));