llvm.org GIT mirror llvm / 08d67c7
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) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60064 91177308-0d34-0410-b5e6-96231b3b80d8 Nuno Lopes 11 years ago
2 changed file(s) with 7 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
171171 //===--------------------------------------------------------------------===//
172172 // Basic ID <-> Name map functionality
173173
174 static AnnotationID getID(const std::string &Name); // Name -> ID
175 static const std::string &getName(AnnotationID ID); // ID -> Name
174 static AnnotationID getID(const char *Name); // Name -> ID
175 static const char *getName(AnnotationID ID); // ID -> Name
176176
177177 // getID - Name -> ID + registration of a factory function for demand driven
178178 // annotation support.
179 static AnnotationID getID(const std::string &Name, Factory Fact,
180 void *Data = 0);
179 static AnnotationID getID(const char *Name, Factory Fact, void *Data = 0);
181180
182181 //===--------------------------------------------------------------------===//
183182 // Annotation creation on demand support...
2626 }
2727 }
2828
29 typedef std::mapstd::string, unsigned> IDMapType;
29 typedef std::mapchar*, unsigned> IDMapType;
3030 static unsigned IDCounter = 0; // Unique ID counter
3131
3232 // Static member to ensure initialiation on demand.
5252 }
5353 }
5454
55 AnnotationID AnnotationManager::getID(const std::string &Name) { // Name -> ID
55 AnnotationID AnnotationManager::getID(const char *Name) { // Name -> ID
5656 IDMapType::iterator I = IDMap->find(Name);
5757 if (I == IDMap->end()) {
5858 (*IDMap)[Name] = IDCounter++; // Add a new element
6363
6464 // getID - Name -> ID + registration of a factory function for demand driven
6565 // annotation support.
66 AnnotationID AnnotationManager::getID(const std::string &Name, Factory Fact,
66 AnnotationID AnnotationManager::getID(const char *Name, Factory Fact,
6767 void *Data) {
6868 AnnotationID Result(getID(Name));
6969 registerAnnotationFactory(Result, Fact, Data);
7373 // getName - This function is especially slow, but that's okay because it should
7474 // only be used for debugging.
7575 //
76 const std::string &AnnotationManager::getName(AnnotationID ID) { // ID -> Name
76 const char *AnnotationManager::getName(AnnotationID ID) { // ID -> Name
7777 IDMapType &TheMap = *IDMap;
7878 for (IDMapType::iterator I = TheMap.begin(); ; ++I) {
7979 assert(I != TheMap.end() && "Annotation ID is unknown!");