[cfe-commits] r39086 - /cfe/cfe/trunk/Basic/FileManager.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:24 2007
New Revision: 39086

URL: http://llvm.org/viewvc/llvm-project?rev=39086&view=rev
Log:
simplify logic, eliminate a copy of string data.

Modified:
    cfe/cfe/trunk/Basic/FileManager.cpp

Modified: cfe/cfe/trunk/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Basic/FileManager.cpp?rev=39086&r1=39085&r2=39086&view=diff

==============================================================================
--- cfe/cfe/trunk/Basic/FileManager.cpp (original)
+++ cfe/cfe/trunk/Basic/FileManager.cpp Wed Jul 11 11:27:24 2007
@@ -95,24 +95,23 @@
   // 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;
   





More information about the cfe-commits mailing list