[llvm-commits] [llvm] r60064 - in /llvm/trunk: include/llvm/Support/Annotation.h lib/Support/Annotation.cpp

Nuno Lopes nunoplopes at sapo.pt
Tue Nov 25 16:00:45 PST 2008


Author: nlopes
Date: Tue Nov 25 18:00:44 2008
New Revision: 60064

URL: http://llvm.org/viewvc/llvm-project?rev=60064&view=rev
Log:
change AnnotationManager to use 'const char*' instead of std::string. this fixes the leakage of those strings and avoids the creation of such strings in static cosntructors (should result in a little improvement of startup time)

Modified:
    llvm/trunk/include/llvm/Support/Annotation.h
    llvm/trunk/lib/Support/Annotation.cpp

Modified: llvm/trunk/include/llvm/Support/Annotation.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Annotation.h?rev=60064&r1=60063&r2=60064&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/Annotation.h (original)
+++ llvm/trunk/include/llvm/Support/Annotation.h Tue Nov 25 18:00:44 2008
@@ -172,13 +172,12 @@
   //===--------------------------------------------------------------------===//
   // Basic ID <-> Name map functionality
 
-  static AnnotationID         getID(const std::string &Name);  // Name -> ID
-  static const std::string &getName(AnnotationID ID);          // ID -> Name
+  static AnnotationID  getID(const char *Name);  // Name -> ID
+  static const char *getName(AnnotationID ID);   // ID -> Name
 
   // getID - Name -> ID + registration of a factory function for demand driven
   // annotation support.
-  static AnnotationID getID(const std::string &Name, Factory Fact,
-                            void *Data = 0);
+  static AnnotationID getID(const char *Name, Factory Fact, void *Data = 0);
 
   //===--------------------------------------------------------------------===//
   // Annotation creation on demand support...

Modified: llvm/trunk/lib/Support/Annotation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Annotation.cpp?rev=60064&r1=60063&r2=60064&view=diff

==============================================================================
--- llvm/trunk/lib/Support/Annotation.cpp (original)
+++ llvm/trunk/lib/Support/Annotation.cpp Tue Nov 25 18:00:44 2008
@@ -27,7 +27,7 @@
   }
 }
 
-typedef std::map<const std::string, unsigned> IDMapType;
+typedef std::map<const char*, unsigned> IDMapType;
 static unsigned IDCounter = 0;  // Unique ID counter
 
 // Static member to ensure initialiation on demand.
@@ -53,7 +53,7 @@
   }
 }
 
-AnnotationID AnnotationManager::getID(const std::string &Name) {  // Name -> ID
+AnnotationID AnnotationManager::getID(const char *Name) {  // Name -> ID
   IDMapType::iterator I = IDMap->find(Name);
   if (I == IDMap->end()) {
     (*IDMap)[Name] = IDCounter++;   // Add a new element
@@ -64,7 +64,7 @@
 
 // getID - Name -> ID + registration of a factory function for demand driven
 // annotation support.
-AnnotationID AnnotationManager::getID(const std::string &Name, Factory Fact,
+AnnotationID AnnotationManager::getID(const char *Name, Factory Fact,
                                       void *Data) {
   AnnotationID Result(getID(Name));
   registerAnnotationFactory(Result, Fact, Data);
@@ -74,7 +74,7 @@
 // getName - This function is especially slow, but that's okay because it should
 // only be used for debugging.
 //
-const std::string &AnnotationManager::getName(AnnotationID ID) {  // ID -> Name
+const char *AnnotationManager::getName(AnnotationID ID) {  // ID -> Name
   IDMapType &TheMap = *IDMap;
   for (IDMapType::iterator I = TheMap.begin(); ; ++I) {
     assert(I != TheMap.end() && "Annotation ID is unknown!");





More information about the llvm-commits mailing list