mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Eliminate the O(n) version of TypeSymbolTable::remove, it is dead. When
inserting a type into the type symbol table, only compute unique name if not in symtab already. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33983 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -113,11 +113,6 @@ public:
|
|||||||
/// @returns the Type that was erased from the symbol table.
|
/// @returns the Type that was erased from the symbol table.
|
||||||
Type* remove(iterator TI);
|
Type* remove(iterator TI);
|
||||||
|
|
||||||
/// Remove a specific Type from the symbol table. This isn't fast, linear
|
|
||||||
/// search, O(n), algorithm.
|
|
||||||
/// @returns true if the erase was successful (TI was found)
|
|
||||||
bool remove(Type* TI);
|
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name AbstractTypeUser Methods
|
/// @name AbstractTypeUser Methods
|
||||||
/// @{
|
/// @{
|
||||||
|
@@ -47,17 +47,6 @@ Type* TypeSymbolTable::lookup(const std::string& Name) const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erase a specific type from the symbol table
|
|
||||||
bool TypeSymbolTable::remove(Type *N) {
|
|
||||||
for (iterator TI = tmap.begin(), TE = tmap.end(); TI != TE; ++TI) {
|
|
||||||
if (TI->second == N) {
|
|
||||||
this->remove(TI);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove - Remove a type from the symbol table...
|
// remove - Remove a type from the symbol table...
|
||||||
Type* TypeSymbolTable::remove(iterator Entry) {
|
Type* TypeSymbolTable::remove(iterator Entry) {
|
||||||
assert(Entry != tmap.end() && "Invalid entry to remove!");
|
assert(Entry != tmap.end() && "Invalid entry to remove!");
|
||||||
@@ -88,19 +77,30 @@ Type* TypeSymbolTable::remove(iterator Entry) {
|
|||||||
void TypeSymbolTable::insert(const std::string& Name, const Type* T) {
|
void TypeSymbolTable::insert(const std::string& Name, const Type* T) {
|
||||||
assert(T && "Can't insert null type into symbol table!");
|
assert(T && "Can't insert null type into symbol table!");
|
||||||
|
|
||||||
// Check to see if there is a naming conflict. If so, rename this type!
|
if (tmap.insert(make_pair(Name, T)).second) {
|
||||||
std::string UniqueName = Name;
|
// Type inserted fine with no conflict.
|
||||||
if (lookup(Name))
|
|
||||||
UniqueName = getUniqueName(Name);
|
|
||||||
|
|
||||||
#if DEBUG_SYMBOL_TABLE
|
#if DEBUG_SYMBOL_TABLE
|
||||||
dump();
|
dump();
|
||||||
cerr << " Inserting type: " << UniqueName << ": "
|
cerr << " Inserted type: " << Name << ": " << T->getDescription() << "\n";
|
||||||
<< T->getDescription() << "\n";
|
#endif
|
||||||
|
} else {
|
||||||
|
// If there is a name conflict...
|
||||||
|
|
||||||
|
// Check to see if there is a naming conflict. If so, rename this type!
|
||||||
|
std::string UniqueName = Name;
|
||||||
|
if (lookup(Name))
|
||||||
|
UniqueName = getUniqueName(Name);
|
||||||
|
|
||||||
|
#if DEBUG_SYMBOL_TABLE
|
||||||
|
dump();
|
||||||
|
cerr << " Inserting type: " << UniqueName << ": "
|
||||||
|
<< T->getDescription() << "\n";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Insert the tmap entry
|
// Insert the tmap entry
|
||||||
tmap.insert(make_pair(UniqueName, T));
|
tmap.insert(make_pair(UniqueName, T));
|
||||||
|
}
|
||||||
|
|
||||||
// If we are adding an abstract type, add the symbol table to it's use list.
|
// If we are adding an abstract type, add the symbol table to it's use list.
|
||||||
if (T->isAbstract()) {
|
if (T->isAbstract()) {
|
||||||
|
Reference in New Issue
Block a user