Don't strlen() every file before parsing it.

llvm-svn: 131132
This commit is contained in:
Eli Friedman 2011-05-10 17:11:21 +00:00
parent 27390b4a0e
commit 86a5101c27
1 changed files with 2 additions and 1 deletions

View File

@ -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);