[cfe-commits] r92358 - /cfe/trunk/lib/Lex/Preprocessor.cpp
Benjamin Kramer
benny.kra at googlemail.com
Thu Dec 31 07:33:09 PST 2009
Author: d0k
Date: Thu Dec 31 09:33:09 2009
New Revision: 92358
URL: http://llvm.org/viewvc/llvm-project?rev=92358&view=rev
Log:
Avoid an unnecessary copy of Predefines. getMemBufferCopy does the null termination for us.
Modified:
cfe/trunk/lib/Lex/Preprocessor.cpp
Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=92358&r1=92357&r2=92358&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Thu Dec 31 09:33:09 2009
@@ -446,19 +446,10 @@
if (const FileEntry *FE = SourceMgr.getFileEntryForID(MainFileID))
HeaderInfo.IncrementIncludeCount(FE);
- std::vector<char> PrologFile;
- PrologFile.reserve(4080);
-
- // FIXME: Don't make a copy.
- PrologFile.insert(PrologFile.end(), Predefines.begin(), Predefines.end());
-
- // Memory buffer must end with a null byte!
- PrologFile.push_back(0);
-
- // Now that we have emitted the predefined macros, #includes, etc into
- // PrologFile, preprocess it to populate the initial preprocessor state.
+ // Preprocess Predefines to populate the initial preprocessor state.
llvm::MemoryBuffer *SB =
- llvm::MemoryBuffer::getMemBufferCopy(&PrologFile.front(),&PrologFile.back(),
+ llvm::MemoryBuffer::getMemBufferCopy(Predefines.data(),
+ Predefines.data() + Predefines.size(),
"<built-in>");
assert(SB && "Cannot fail to create predefined source buffer");
FileID FID = SourceMgr.createFileIDForMemBuffer(SB);
More information about the cfe-commits
mailing list