aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2006-12-29 15:43:55 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2006-12-29 15:43:55 +0000
commit7af45bd465a9d75ea3eeb95b94ad06697989b84b (patch)
treed65c0563731fbeda76b7bc10f898ca429033ba53 /libcpp
parenta3993f33507e06424e79fd279f0f546798664440 (diff)
lex.c (_cpp_clean_line): Add uses of __builtin_expect.
* lex.c (_cpp_clean_line): Add uses of __builtin_expect. Don't look backward at the end of the line unless we saw a backslash. From-SVN: r120263
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog5
-rw-r--r--libcpp/lex.c30
2 files changed, 26 insertions, 9 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index de8eb92095c..96c5140e707 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,8 @@
+2006-12-29 Ian Lance Taylor <iant@google.com>
+
+ * lex.c (_cpp_clean_line): Add uses of __builtin_expect. Don't
+ look backward at the end of the line unless we saw a backslash.
+
2006-12-29 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/29612
diff --git a/libcpp/lex.c b/libcpp/lex.c
index df09bd6d3d6..5d1a688af9a 100644
--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -111,31 +111,39 @@ _cpp_clean_line (cpp_reader *pfile)
if (!buffer->from_stage3)
{
+ const uchar *pbackslash = NULL;
+
/* 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')
+ if (__builtin_expect (c == '\n', false)
+ || __builtin_expect (c == '\r', false))
{
d = (uchar *) s;
- if (s == buffer->rlimit)
+ if (__builtin_expect (s == buffer->rlimit, false))
goto done;
/* DOS line ending? */
- if (c == '\r' && s[1] == '\n')
- s++;
+ if (__builtin_expect (c == '\r', false)
+ && s[1] == '\n')
+ {
+ s++;
+ if (s == buffer->rlimit)
+ goto done;
+ }
- if (s == buffer->rlimit)
+ if (__builtin_expect (pbackslash == NULL, true))
goto done;
- /* check for escaped newline */
+ /* Check for escaped newline. */
p = d;
- while (p != buffer->next_line && is_nvspace (p[-1]))
+ while (is_nvspace (p[-1]))
p--;
- if (p == buffer->next_line || p[-1] != '\\')
+ if (p - 1 != pbackslash)
goto done;
/* Have an escaped newline; process it and proceed to
@@ -145,7 +153,11 @@ _cpp_clean_line (cpp_reader *pfile)
buffer->next_line = p - 1;
break;
}
- if (c == '?' && s[1] == '?' && _cpp_trigraph_map[s[2]])
+ if (__builtin_expect (c == '\\', false))
+ pbackslash = s;
+ else if (__builtin_expect (c == '?', false)
+ && __builtin_expect (s[1] == '?', false)
+ && _cpp_trigraph_map[s[2]])
{
/* Have a trigraph. We may or may not have to convert
it. Add a line note regardless, for -Wtrigraphs. */