[cfe-commits] r39087 - /cfe/cfe/trunk/Lex/HeaderSearch.cpp
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:27:25 PDT 2007
Author: sabre
Date: Wed Jul 11 11:27:25 2007
New Revision: 39087
URL: http://llvm.org/viewvc/llvm-project?rev=39087&view=rev
Log:
Use SmallString instead of string in HeaderSearch::LookupFile. This avoids
malloc traffic, speeding up user time preprocessing Carbon.h 5% (0.083s to
0.079s).
Modified:
cfe/cfe/trunk/Lex/HeaderSearch.cpp
Modified: cfe/cfe/trunk/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/HeaderSearch.cpp?rev=39087&r1=39086&r2=39087&view=diff
==============================================================================
--- cfe/cfe/trunk/Lex/HeaderSearch.cpp (original)
+++ cfe/cfe/trunk/Lex/HeaderSearch.cpp Wed Jul 11 11:27:25 2007
@@ -126,19 +126,24 @@
return FileMgr.getFile(Filename);
}
+ SmallString<1024> TmpDir;
+
// Step #0, unless disabled, check to see if the file is in the #includer's
// directory. This search is not done for <> headers.
if (CurFileEnt && !isAngled && !NoCurDirSearch) {
// Concatenate the requested file onto the directory.
// FIXME: Portability. Filename concatenation should be in sys::Path.
- std::string Name = CurFileEnt->getDir()->getName();
- if (const FileEntry *FE = FileMgr.getFile(Name+"/"+Filename)) {
+ TmpDir += CurFileEnt->getDir()->getName();
+ TmpDir.push_back('/');
+ TmpDir.append(Filename.begin(), Filename.end());
+ if (const FileEntry *FE = FileMgr.getFile(TmpDir.begin(), TmpDir.end())) {
// Leave CurDir unset.
// This file is a system header or C++ unfriendly if the old file is.
getFileInfo(FE).DirInfo = getFileInfo(CurFileEnt).DirInfo;
return FE;
}
+ TmpDir.clear();
}
CurDir = 0;
@@ -153,14 +158,15 @@
// Check each directory in sequence to see if it contains this file.
for (; i != SearchDirs.size(); ++i) {
- // Concatenate the requested file onto the directory.
- std::string SearchDir;
-
const FileEntry *FE = 0;
if (!SearchDirs[i].isFramework()) {
// FIXME: Portability. Adding file to dir should be in sys::Path.
- std::string Name = SearchDirs[i].getDir()->getName();
- FE = FileMgr.getFile(Name+"/"+Filename);
+ // Concatenate the requested file onto the directory.
+ TmpDir.clear();
+ TmpDir += SearchDirs[i].getDir()->getName();
+ TmpDir.push_back('/');
+ TmpDir.append(Filename.begin(), Filename.end());
+ FE = FileMgr.getFile(TmpDir.begin(), TmpDir.end());
} else {
FE = DoFrameworkLookup(SearchDirs[i].getDir(), Filename);
}
More information about the cfe-commits
mailing list