(collect_expansion): Assume leading white space already removed.
authorRichard Kenner <kenner@gcc.gnu.org>
Thu, 27 Apr 1995 11:08:53 +0000 (07:08 -0400)
committerRichard Kenner <kenner@gcc.gnu.org>
Thu, 27 Apr 1995 11:08:53 +0000 (07:08 -0400)
Don't allocate unnecessary space for expansion.

From-SVN: r9502

gcc/cccp.c

index a7949872d971c168182f8a58c0761a4ca00c2772..0bc6a5a1baf0213878bf1d1fcdc62bb0c73bc861 100644 (file)
@@ -5905,16 +5905,10 @@ comp_def_part (first, beg1, len1, beg2, len2, last)
    MACRONAME is the macro name itself (so we can avoid recursive expansion)
    and NAMELEN is its length in characters.
    
-Note that comments and backslash-newlines have already been deleted
-from the argument.  */
+Note that comments, backslash-newlines, and leading white space
+have already been deleted from the argument.  */
 
-/* Leading and trailing Space, Tab, etc. are converted to markers
-   Newline Space, Newline Tab, etc.
-   Newline Space makes a space in the final output
-   but is discarded if stringified.  (Newline Tab is similar but
-   makes a Tab instead.)
-
-   If there is no trailing whitespace, a Newline Space is added at the end
+/* If there is no trailing whitespace, a Newline Space is added at the end
    to prevent concatenation that would be contrary to the standard.  */
 
 static DEFINITION *
@@ -5945,19 +5939,15 @@ collect_expansion (buf, end, nargs, arglist)
     abort ();
 
   /* Find the beginning of the trailing whitespace.  */
-  /* Find end of leading whitespace.  */
   limit = end;
   p = buf;
   while (p < limit && is_space[limit[-1]]) limit--;
-  while (p < limit && is_space[*p]) p++;
 
   /* Allocate space for the text in the macro definition.
-     Leading and trailing whitespace chars need 2 bytes each.
-     Each other input char may or may not need 1 byte,
+     Each input char may or may not need 1 byte,
      so this is an upper bound.
-     The extra 2 are for invented trailing newline-marker and final null.  */
+     The extra 3 are for invented trailing newline-marker and final null.  */
   maxsize = (sizeof (DEFINITION)
-            + 2 * (end - limit) + 2 * (p - buf)
             + (limit - p) + 3);
   defn = (DEFINITION *) xcalloc (1, maxsize);
 
@@ -5965,14 +5955,6 @@ collect_expansion (buf, end, nargs, arglist)
   exp_p = defn->expansion = (U_CHAR *) defn + sizeof (DEFINITION);
   lastp = exp_p;
 
-  p = buf;
-
-  /* Convert leading whitespace to Newline-markers.  */
-  while (p < limit && is_space[*p]) {
-    *exp_p++ = '\n';
-    *exp_p++ = *p++;
-  }
-
   if (p[0] == '#'
       ? p[1] == '#'
       : p[0] == '%' && p[1] == ':' && p[2] == '%' && p[3] == ':') {