summaryrefslogtreecommitdiffstats
path: root/clang/Lex/Lexer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-10-27 04:12:35 +0000
committerChris Lattner <sabre@nondot.org>2006-10-27 04:12:35 +0000
commit6cc3e36cd7f952d31ed24be277db9f1efa34e839 (patch)
tree7d98ca8410151c6576a9ae9e72eff5400ab7addf /clang/Lex/Lexer.cpp
parentf2e3ac3b5478424f248969db01550b01f35ddc96 (diff)
downloadbcm5719-llvm-6cc3e36cd7f952d31ed24be277db9f1efa34e839.tar.gz
bcm5719-llvm-6cc3e36cd7f952d31ed24be277db9f1efa34e839.zip
Speed up block comment skipping by 35%.
llvm-svn: 39059
Diffstat (limited to 'clang/Lex/Lexer.cpp')
-rw-r--r--clang/Lex/Lexer.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp
index eb2e1e3b24c..c8433559927 100644
--- a/clang/Lex/Lexer.cpp
+++ b/clang/Lex/Lexer.cpp
@@ -789,11 +789,31 @@ bool Lexer::SkipBlockComment(LexerToken &Result, const char *CurPtr) {
}
while (1) {
- // Skip over all non-interesting characters.
+ // Skip over all non-interesting characters until we find end of buffer or a
+ // (probably ending) '/' character.
// TODO: Vectorize this. Note: memchr on Darwin is slower than this loop.
+
+ if (CurPtr + 24 < BufferEnd) {
+ // While not aligned to a 16-byte boundary.
+ while (C != '/' && ((intptr_t)CurPtr & 0x0F) != 0)
+ C = *CurPtr++;
+
+ if (C == '/') goto FoundSlash;
+
+ while (CurPtr[0] != '/' &&
+ CurPtr[1] != '/' &&
+ CurPtr[2] != '/' &&
+ CurPtr[3] != '/' &&
+ CurPtr+4 < BufferEnd) {
+ CurPtr += 4;
+ }
+ C = *CurPtr++;
+ }
+
while (C != '/' && C != '\0')
C = *CurPtr++;
+ FoundSlash:
if (C == '/') {
if (CurPtr[-2] == '*') // We found the final */. We're done!
break;
OpenPOWER on IntegriCloud