]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cpplex.c (_cpp_clean_line): In the common case of a line with no trigraphs and no...
authorZack Weinberg <zack@gcc.gnu.org>
Mon, 13 Oct 2003 18:53:28 +0000 (18:53 +0000)
committerZack Weinberg <zack@gcc.gnu.org>
Mon, 13 Oct 2003 18:53:28 +0000 (18:53 +0000)
* cpplex.c (_cpp_clean_line): In the common case of a line
with no trigraphs and no \-newline, avoid writing to memory.
(_cpp_skip_block_comment): Use a local 'cur' pointer instead
of the buffer member.  Make c an uchar to avoid unnecessary
sign extensions.

From-SVN: r72437

gcc/ChangeLog
gcc/cpplex.c

index dddfe9a57c594bd4465c1c0aff0825921adec0d7..584fd728130a9ca8ae8650143d0e0805c29b746a 100644 (file)
@@ -1,3 +1,11 @@
+2003-10-13  Zack Weinberg  <zack@codesourcery.com>
+
+       * cpplex.c (_cpp_clean_line): In the common case of a line
+       with no trigraphs and no \-newline, avoid writing to memory.
+       (_cpp_skip_block_comment): Use a local 'cur' pointer instead
+       of the buffer member.  Make c an uchar to avoid unnecessary
+       sign extensions.
+
 2003-10-13  Nathanael Nerode  <neroden@gcc.gnu.org>
 
        * configure.in: Remove unnecessary test.
 
 2003-10-13  Andreas Krebbel  <krebbel1@de.ibm.com>
 
-       * config/s390/s390.md ("*fmadddf4", "*fmsubdf4", "*fmaddsf4", 
+       * config/s390/s390.md ("*fmadddf4", "*fmsubdf4", "*fmaddsf4",
        "*fmsubsf4"): Insns are now dependent on TARGET_FUSED_MADD instead
        of flag_unsafe_math_optimizations.
        * config/s390/s390.h ("MASK_NO_FUSED_MADD", "TARGET_NO_FUSED_MADD",
        "TARGET_FUSED_MADD", "TARGET_SWITCHES"): Introduced new target flags
        fused-madd and no-fused-madd.
-       * doc/invoke.texi: Documented the new options fused-madd and 
+       * doc/invoke.texi: Documented the new options fused-madd and
        no-fused-madd for S/390.
 
 2003-10-14  Alan Modra  <amodra@bigpond.net.au>
        and the signed type would overflow.  Always negate real constants
        unless we honor -ftrapping-math.  Only convert -(A-B) into B-A
        if allowed by reorder_operands_p.  Add support for COMPLEX_CST.
-       Optimize negation through floating point extensions and 
+       Optimize negation through floating point extensions and
        sign-preserving built-in functions (as defined by negate_mathfn_p).
        (fold): Adjust calls to tree_swap_operands_p.
        (fold <NEGATE_EXPR>): Move the remaining negation optimizations
@@ -226,7 +234,7 @@ Sat Oct 11 12:24:23 CEST 2003  Jan Hubicka  <jh@suse.cz>
        point optimizations with -funsafe-math-optimizations.
 
 2003-10-11  Andrew Pinski <pinskia@physics.uc.edu>
-       
+
        * genmodes.c (emit_mode_mask) Change MASK to MODE_MASK.
 
 2003-10-11  Kazu Hirata  <kazu@cs.umass.edu>
@@ -298,7 +306,7 @@ Sat Oct 11 12:24:23 CEST 2003  Jan Hubicka  <jh@suse.cz>
            Paul Dale  <pauli@snapgear.com>
 
        * config/m68k/lb1sf68.asm: Add __PIC__ and __ID_SHARED_LIBRARY__
-       support. 
+       support.
        * config/m68k/m68k-none.h (ASM_SPEC): Pass --pcrel to assembler on
        -fpic, -fPIC, -msep-data and -mid-shared-library.
        * config/m68k/m68k.c (m68k_library_id_string): New global variable.
index 45cf5741b6683e5086681d987983a29b76ee2087..3701415aa326d463105c67abadc2672c6207c30e 100644 (file)
@@ -114,7 +114,57 @@ _cpp_clean_line (cpp_reader *pfile)
 
   if (!buffer->from_stage3)
     {
-      d = (uchar *) s;
+      /* Short circuit for the common case of an un-escaped line with
+        no trigraphs.  The primary win here is by not writing any
+        data back to memory until we have to.  */
+      for (;;)
+       {
+         c = *++s;
+         if (c == '\n' || c == '\r')
+           {
+             d = (uchar *) s;
+
+             if (s == buffer->rlimit)
+               goto done;
+
+             /* DOS line ending? */
+             if (c == '\r' && s[1] == '\n')
+               s++;
+
+             if (s == buffer->rlimit)
+               goto done;
+
+             /* check for escaped newline */
+             p = d;
+             while (p != buffer->next_line && is_nvspace (p[-1]))
+               p--;
+             if (p == buffer->next_line || p[-1] != '\\')
+               goto done;
+
+             /* Have an escaped newline; process it and proceed to
+                the slow path.  */
+             add_line_note (buffer, p - 1, p != d ? ' ' : '\\');
+             d = p - 2;
+             buffer->next_line = p - 1;
+             break;
+           }
+         if (c == '?' && s[1] == '?' && _cpp_trigraph_map[s[2]])
+           {
+             /* Have a trigraph.  We may or may not have to convert
+                it.  Add a line note regardless, for -Wtrigraphs.  */
+             add_line_note (buffer, s, s[2]);
+             if (CPP_OPTION (pfile, trigraphs))
+               {
+                 /* We do, and that means we have to switch to the
+                    slow path.  */
+                 d = (uchar *) s;
+                 *d = _cpp_trigraph_map[s[2]];
+                 s += 2;
+                 break;
+               }
+           }
+       }
+
 
       for (;;)
        {
@@ -164,6 +214,7 @@ _cpp_clean_line (cpp_reader *pfile)
        s++;
     }
 
+ done:
   *d = '\n';
   /* A sentinel note that should never be processed.  */
   add_line_note (buffer, d + 1, '\n');
@@ -266,43 +317,49 @@ bool
 _cpp_skip_block_comment (cpp_reader *pfile)
 {
   cpp_buffer *buffer = pfile->buffer;
-  cppchar_t c;
+  const uchar *cur = buffer->cur;
+  uchar c;
 
-  buffer->cur++;
-  if (*buffer->cur == '/')
-    buffer->cur++;
+  cur++;
+  if (*cur == '/')
+    cur++;
 
   for (;;)
     {
-      c = *buffer->cur++;
-
       /* People like decorating comments with '*', so check for '/'
         instead for efficiency.  */
+      c = *cur++;
+
       if (c == '/')
        {
-         if (buffer->cur[-2] == '*')
+         if (cur[-2] == '*')
            break;
 
          /* Warn about potential nested comments, but not if the '/'
             comes immediately before the true comment delimiter.
             Don't bother to get it right across escaped newlines.  */
          if (CPP_OPTION (pfile, warn_comments)
-             && buffer->cur[0] == '*' && buffer->cur[1] != '/')
-           cpp_error_with_line (pfile, DL_WARNING,
-                                pfile->line, CPP_BUF_COL (buffer),
-                                "\"/*\" within comment");
+             && cur[0] == '*' && cur[1] != '/')
+           {
+             buffer->cur = cur;
+             cpp_error_with_line (pfile, DL_WARNING,
+                                  pfile->line, CPP_BUF_COL (buffer),
+                                  "\"/*\" within comment");
+           }
        }
       else if (c == '\n')
        {
-         buffer->cur--;
+         buffer->cur = cur - 1;
          _cpp_process_line_notes (pfile, true);
          if (buffer->next_line >= buffer->rlimit)
            return true;
          _cpp_clean_line (pfile);
          pfile->line++;
+         cur = buffer->cur;
        }
     }
 
+  buffer->cur = cur;
   _cpp_process_line_notes (pfile, true);
   return false;
 }