mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
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
This commit is contained in:
parent
75ea1933a5
commit
08d67c7763
@ -172,13 +172,12 @@ struct AnnotationManager {
|
|||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Basic ID <-> Name map functionality
|
// Basic ID <-> Name map functionality
|
||||||
|
|
||||||
static AnnotationID getID(const std::string &Name); // Name -> ID
|
static AnnotationID getID(const char *Name); // Name -> ID
|
||||||
static const std::string &getName(AnnotationID ID); // ID -> Name
|
static const char *getName(AnnotationID ID); // ID -> Name
|
||||||
|
|
||||||
// getID - Name -> ID + registration of a factory function for demand driven
|
// getID - Name -> ID + registration of a factory function for demand driven
|
||||||
// annotation support.
|
// annotation support.
|
||||||
static AnnotationID getID(const std::string &Name, Factory Fact,
|
static AnnotationID getID(const char *Name, Factory Fact, void *Data = 0);
|
||||||
void *Data = 0);
|
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Annotation creation on demand support...
|
// Annotation creation on demand support...
|
||||||
|
@ -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 unsigned IDCounter = 0; // Unique ID counter
|
||||||
|
|
||||||
// Static member to ensure initialiation on demand.
|
// 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);
|
IDMapType::iterator I = IDMap->find(Name);
|
||||||
if (I == IDMap->end()) {
|
if (I == IDMap->end()) {
|
||||||
(*IDMap)[Name] = IDCounter++; // Add a new element
|
(*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
|
// getID - Name -> ID + registration of a factory function for demand driven
|
||||||
// annotation support.
|
// annotation support.
|
||||||
AnnotationID AnnotationManager::getID(const std::string &Name, Factory Fact,
|
AnnotationID AnnotationManager::getID(const char *Name, Factory Fact,
|
||||||
void *Data) {
|
void *Data) {
|
||||||
AnnotationID Result(getID(Name));
|
AnnotationID Result(getID(Name));
|
||||||
registerAnnotationFactory(Result, Fact, Data);
|
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
|
// getName - This function is especially slow, but that's okay because it should
|
||||||
// only be used for debugging.
|
// 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;
|
IDMapType &TheMap = *IDMap;
|
||||||
for (IDMapType::iterator I = TheMap.begin(); ; ++I) {
|
for (IDMapType::iterator I = TheMap.begin(); ; ++I) {
|
||||||
assert(I != TheMap.end() && "Annotation ID is unknown!");
|
assert(I != TheMap.end() && "Annotation ID is unknown!");
|
||||||
|
Loading…
Reference in New Issue
Block a user