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
This commit is contained in:
Ian Lance Taylor 2006-12-29 15:43:55 +00:00 committed by Ian Lance Taylor
parent a3993f3350
commit 7af45bd465
2 changed files with 26 additions and 9 deletions

View File

@ -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> 2006-12-29 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/29612 PR preprocessor/29612

View File

@ -111,31 +111,39 @@ _cpp_clean_line (cpp_reader *pfile)
if (!buffer->from_stage3) if (!buffer->from_stage3)
{ {
const uchar *pbackslash = NULL;
/* Short circuit for the common case of an un-escaped line with /* Short circuit for the common case of an un-escaped line with
no trigraphs. The primary win here is by not writing any no trigraphs. The primary win here is by not writing any
data back to memory until we have to. */ data back to memory until we have to. */
for (;;) for (;;)
{ {
c = *++s; c = *++s;
if (c == '\n' || c == '\r') if (__builtin_expect (c == '\n', false)
|| __builtin_expect (c == '\r', false))
{ {
d = (uchar *) s; d = (uchar *) s;
if (s == buffer->rlimit) if (__builtin_expect (s == buffer->rlimit, false))
goto done; goto done;
/* DOS line ending? */ /* DOS line ending? */
if (c == '\r' && s[1] == '\n') if (__builtin_expect (c == '\r', false)
&& s[1] == '\n')
{
s++; s++;
if (s == buffer->rlimit) if (s == buffer->rlimit)
goto done; goto done;
}
/* check for escaped newline */ if (__builtin_expect (pbackslash == NULL, true))
goto done;
/* Check for escaped newline. */
p = d; p = d;
while (p != buffer->next_line && is_nvspace (p[-1])) while (is_nvspace (p[-1]))
p--; p--;
if (p == buffer->next_line || p[-1] != '\\') if (p - 1 != pbackslash)
goto done; goto done;
/* Have an escaped newline; process it and proceed to /* Have an escaped newline; process it and proceed to
@ -145,7 +153,11 @@ _cpp_clean_line (cpp_reader *pfile)
buffer->next_line = p - 1; buffer->next_line = p - 1;
break; 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 /* Have a trigraph. We may or may not have to convert
it. Add a line note regardless, for -Wtrigraphs. */ it. Add a line note regardless, for -Wtrigraphs. */