[cfe-commits] r131132 - /cfe/trunk/lib/Lex/Lexer.cpp
Eli Friedman
eli.friedman at gmail.com
Tue May 10 10:11:21 PDT 2011
Author: efriedma
Date: Tue May 10 12:11:21 2011
New Revision: 131132
URL: http://llvm.org/viewvc/llvm-project?rev=131132&view=rev
Log:
Don't strlen() every file before parsing it.
Modified:
cfe/trunk/lib/Lex/Lexer.cpp
Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=131132&r1=131131&r2=131132&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Tue May 10 12:11:21 2011
@@ -76,7 +76,8 @@
// skip the UTF-8 BOM if it's present.
if (BufferStart == BufferPtr) {
// Determine the size of the BOM.
- size_t BOMLength = llvm::StringSwitch<size_t>(BufferStart)
+ llvm::StringRef Buf(BufferStart, BufferEnd - BufferStart);
+ size_t BOMLength = llvm::StringSwitch<size_t>(Buf)
.StartsWith("\xEF\xBB\xBF", 3) // UTF-8 BOM
.Default(0);
More information about the cfe-commits
mailing list