Commit 7af45bd4 by Ian Lance Taylor Committed by Ian Lance Taylor

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
parent a3993f33
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
......
......@@ -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. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment