From: Eli Friedman Date: Tue, 10 May 2011 17:11:21 +0000 (+0000) Subject: Don't strlen() every file before parsing it. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=969f9d47338fc36ebb6d24ad3a51e45eda07fd58;p=clang 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 --- 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(BufferStart) + llvm::StringRef Buf(BufferStart, BufferEnd - BufferStart); + size_t BOMLength = llvm::StringSwitch(Buf) .StartsWith("\xEF\xBB\xBF", 3) // UTF-8 BOM .Default(0);