diff options
| author | Nuno Lopes <nunoplopes@sapo.pt> | 2008-11-26 00:00:44 +0000 |
|---|---|---|
| committer | Nuno Lopes <nunoplopes@sapo.pt> | 2008-11-26 00:00:44 +0000 |
| commit | b472c9fac7a186aecfd436eb32eb81e088ed0064 (patch) | |
| tree | a6152d0f549ce0ade571bee6054f55a592594132 /llvm | |
| parent | 762e77b55f883acc3dc74f202b14775c444c4761 (diff) | |
| download | bcm5719-llvm-b472c9fac7a186aecfd436eb32eb81e088ed0064.tar.gz bcm5719-llvm-b472c9fac7a186aecfd436eb32eb81e088ed0064.zip | |
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)
llvm-svn: 60064
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/Support/Annotation.h | 7 | ||||
| -rw-r--r-- | llvm/lib/Support/Annotation.cpp | 8 |
2 files changed, 7 insertions, 8 deletions
diff --git a/llvm/include/llvm/Support/Annotation.h b/llvm/include/llvm/Support/Annotation.h index 2be1c106169..dcdcf224545 100644 --- a/llvm/include/llvm/Support/Annotation.h +++ b/llvm/include/llvm/Support/Annotation.h @@ -172,13 +172,12 @@ struct AnnotationManager { //===--------------------------------------------------------------------===// // 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... diff --git a/llvm/lib/Support/Annotation.cpp b/llvm/lib/Support/Annotation.cpp index 3ecc42f782e..38b06070867 100644 --- a/llvm/lib/Support/Annotation.cpp +++ b/llvm/lib/Support/Annotation.cpp @@ -27,7 +27,7 @@ Annotable::~Annotable() { // Virtual because it's designed to be subclassed... } } -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 @@ static void eraseFromFactMap(unsigned ID) { } } -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 @@ AnnotationID AnnotationManager::getID(const std::string &Name) { // Name -> ID // 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 @@ AnnotationID AnnotationManager::getID(const std::string &Name, Factory Fact, // 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!"); |

