summaryrefslogtreecommitdiffstats
path: root/clang/Basic/FileManager.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-10-30 03:40:58 +0000
committerChris Lattner <sabre@nondot.org>2006-10-30 03:40:58 +0000
commit43fd42e4d95913b2f69410556b0b00a90c977e08 (patch)
tree13689261ce12e94ab657cd8b64e400511d45e417 /clang/Basic/FileManager.cpp
parenta85cbe28a0166d4a752b01cee4eda66a99a37a1a (diff)
downloadbcm5719-llvm-43fd42e4d95913b2f69410556b0b00a90c977e08.tar.gz
bcm5719-llvm-43fd42e4d95913b2f69410556b0b00a90c977e08.zip
Wean LookupSubframeworkHeader off std::strings, use the new SmallString
class instead. SmallString allows to code to avoid hitting malloc in the normal case (or will, when some other stuff is converted over). llvm-svn: 39084
Diffstat (limited to 'clang/Basic/FileManager.cpp')
-rw-r--r--clang/Basic/FileManager.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/clang/Basic/FileManager.cpp b/clang/Basic/FileManager.cpp
index 5ee032ef033..891b81d106f 100644
--- a/clang/Basic/FileManager.cpp
+++ b/clang/Basic/FileManager.cpp
@@ -33,11 +33,10 @@ using namespace clang;
/// getDirectory - Lookup, cache, and verify the specified directory. This
/// returns null if the directory doesn't exist.
///
-const DirectoryEntry *FileManager::getDirectory(const std::string &Filename) {
+const DirectoryEntry *FileManager::getDirectory(const char *FileStart,
+ const char *FileEnd) {
++NumDirLookups;
-
- DirectoryEntry *&NamedDirEnt =
- DirEntries.GetOrCreateValue(&Filename[0], &Filename[0] + Filename.size());
+ DirectoryEntry *&NamedDirEnt =DirEntries.GetOrCreateValue(FileStart, FileEnd);
// See if there is already an entry in the map.
if (NamedDirEnt)
@@ -48,10 +47,14 @@ const DirectoryEntry *FileManager::getDirectory(const std::string &Filename) {
// By default, initialize it to invalid.
NamedDirEnt = NON_EXISTANT_DIR;
+ // Get the null-terminated directory name as stored as the key of the
+ // DirEntries map.
+ const char *InterndDirName = DirEntries.GetKeyForValueInMap(NamedDirEnt);
+
// Check to see if the directory exists.
struct stat StatBuf;
- if (stat(Filename.c_str(), &StatBuf) || // Error stat'ing.
- !S_ISDIR(StatBuf.st_mode)) // Not a directory?
+ if (stat(InterndDirName, &StatBuf) || // Error stat'ing.
+ !S_ISDIR(StatBuf.st_mode)) // Not a directory?
return 0;
// It exists. See if we have already opened a directory with the same inode.
@@ -64,7 +67,7 @@ const DirectoryEntry *FileManager::getDirectory(const std::string &Filename) {
// Otherwise, we don't have this directory yet, add it. We use the string
// key from the DirEntries map as the string.
- UDE.Name = DirEntries.GetKeyForValueInMap(NamedDirEnt);
+ UDE.Name = InterndDirName;
return NamedDirEnt = &UDE;
}
OpenPOWER on IntegriCloud