diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-10-30 04:34:28 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-10-30 04:34:28 +0000 |
| commit | 9c59bdace484e42b2f4e59f271b3fa464bf47b8f (patch) | |
| tree | 5001d8b38ecbc1046dd258b3b4221cf22835813d /clang/Basic/FileManager.cpp | |
| parent | 2f4a89a5e8b99ac97fe0ac05fdabe1113111af44 (diff) | |
| download | bcm5719-llvm-9c59bdace484e42b2f4e59f271b3fa464bf47b8f.tar.gz bcm5719-llvm-9c59bdace484e42b2f4e59f271b3fa464bf47b8f.zip | |
simplify logic, eliminate a copy of string data.
llvm-svn: 39086
Diffstat (limited to 'clang/Basic/FileManager.cpp')
| -rw-r--r-- | clang/Basic/FileManager.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/clang/Basic/FileManager.cpp b/clang/Basic/FileManager.cpp index 6ae0031ba9b..3ca9c8cbde8 100644 --- a/clang/Basic/FileManager.cpp +++ b/clang/Basic/FileManager.cpp @@ -95,24 +95,23 @@ const FileEntry *FileManager::getFile(const char *NameStart, // By default, initialize it to invalid. NamedFileEnt = NON_EXISTANT_FILE; - // Figure out what directory it is in. - SmallString<1024> DirName; - - // If the string contains a / in it, strip off everything after it. + // Figure out what directory it is in. If the string contains a / in it, + // strip off everything after it. // FIXME: this logic should be in sys::Path. const char *SlashPos = NameEnd-1; while (SlashPos >= NameStart && SlashPos[0] != '/') --SlashPos; + const DirectoryEntry *DirInfo; if (SlashPos < NameStart) { // Use the current directory if file has no path component. - DirName.push_back('.'); + const char *Name = "."; + DirInfo = getDirectory(Name, Name+1); } else if (SlashPos == NameEnd-1) return 0; // If filename ends with a /, it's a directory. else - DirName.append(NameStart, SlashPos); - - const DirectoryEntry *DirInfo = getDirectory(DirName.begin(), DirName.end()); + DirInfo = getDirectory(NameStart, SlashPos); + if (DirInfo == 0) // Directory doesn't exist, file can't exist. return 0; |

