diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2011-05-10 17:11:21 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2011-05-10 17:11:21 +0000 |
commit | 969f9d47338fc36ebb6d24ad3a51e45eda07fd58 (patch) | |
tree | e660883a73d6f4ec6df8a953a8e2e392cd8bbe76 /lib/Lex/Lexer.cpp | |
parent | 8d6dd72e79a847e8eb4a72f108362664b237c44b (diff) |
Don't strlen() every file before parsing it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131132 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Lexer.cpp')
-rw-r--r-- | lib/Lex/Lexer.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index 16cc4f8fd5..3b1149c08a 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -76,7 +76,8 @@ void Lexer::InitLexer(const char *BufStart, const char *BufPtr, // 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); |