[cfe-commits] r39083 - in /cfe/cfe/trunk: Basic/FileManager.cpp include/clang/Basic/FileManager.h

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:27:23 PDT 2007


Author: sabre
Date: Wed Jul 11 11:27:23 2007
New Revision: 39083

URL: http://llvm.org/viewvc/llvm-project?rev=39083&view=rev
Log:
Avoid storing a directory name in both the DirEntries map keys and in the
UniqueDirs value.  Instead, just have the UniqueDirs value contain a pointer
to the key in the DirEntries map.

Modified:
    cfe/cfe/trunk/Basic/FileManager.cpp
    cfe/cfe/trunk/include/clang/Basic/FileManager.h

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

==============================================================================
--- cfe/cfe/trunk/Basic/FileManager.cpp (original)
+++ cfe/cfe/trunk/Basic/FileManager.cpp Wed Jul 11 11:27:23 2007
@@ -59,11 +59,12 @@
   DirectoryEntry &UDE = 
     UniqueDirs[std::make_pair(StatBuf.st_dev, StatBuf.st_ino)];
   
-  if (UDE.getName()[0])  // Already have an entry with this inode, return it.
+  if (UDE.getName())  // Already have an entry with this inode, return it.
     return NamedDirEnt = &UDE;
   
-  // Otherwise, we don't have this directory yet, add it.
-  UDE.Name   = 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);
   return NamedDirEnt = &UDE;
 }
 

Modified: cfe/cfe/trunk/include/clang/Basic/FileManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Basic/FileManager.h?rev=39083&r1=39082&r2=39083&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/cfe/trunk/include/clang/Basic/FileManager.h Wed Jul 11 11:27:23 2007
@@ -27,11 +27,11 @@
 /// DirectoryEntry - Cached information about one directory on the disk.
 ///
 class DirectoryEntry {
-  std::string Name;   // Name of the directory.
+  const char *Name;   // Name of the directory.
   friend class FileManager;
 public:
-  DirectoryEntry() {}
-  const char *getName() const { return Name.c_str(); }
+  DirectoryEntry() : Name(0) {}
+  const char *getName() const { return Name; }
 };
 
 /// FileEntry - Cached information about one file on the disk.





More information about the cfe-commits mailing list