aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-06 06:04:35 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-06 06:04:35 +0000
commit8113c6739e854d94910491965d83797487bc8a54 (patch)
tree41f275b338d41d9b59b3db2590544149dce62238 /lib/VMCore
parent902cf02b0a79e1aaedaf8bb90511e5a92dd37532 (diff)
downloadexternal_llvm-8113c6739e854d94910491965d83797487bc8a54.zip
external_llvm-8113c6739e854d94910491965d83797487bc8a54.tar.gz
external_llvm-8113c6739e854d94910491965d83797487bc8a54.tar.bz2
Don't search the entire type table just to delete a type by name.
- This also fixes the ENABLE_EXPENSIVE_CHECKS failure on vmcore.ml. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78287 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Core.cpp12
-rw-r--r--lib/VMCore/TypeSymbolTable.cpp11
2 files changed, 16 insertions, 7 deletions
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp
index 6cce678..88160e1 100644
--- a/lib/VMCore/Core.cpp
+++ b/lib/VMCore/Core.cpp
@@ -94,17 +94,15 @@ int LLVMAddTypeName(LLVMModuleRef M, const char *Name, LLVMTypeRef Ty) {
}
void LLVMDeleteTypeName(LLVMModuleRef M, const char *Name) {
- std::string N(Name);
-
TypeSymbolTable &TST = unwrap(M)->getTypeSymbolTable();
- for (TypeSymbolTable::iterator I = TST.begin(), E = TST.end(); I != E; ++I)
- if (I->first == N)
- TST.remove(I);
+
+ TypeSymbolTable::iterator I = TST.find(Name);
+ if (I != TST.end())
+ TST.remove(I);
}
LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name) {
- std::string N(Name);
- return wrap(unwrap(M)->getTypeByName(N));
+ return wrap(unwrap(M)->getTypeByName(Name));
}
void LLVMDumpModule(LLVMModuleRef M) {
diff --git a/lib/VMCore/TypeSymbolTable.cpp b/lib/VMCore/TypeSymbolTable.cpp
index e9c6255..5fa8785 100644
--- a/lib/VMCore/TypeSymbolTable.cpp
+++ b/lib/VMCore/TypeSymbolTable.cpp
@@ -59,6 +59,17 @@ Type* TypeSymbolTable::lookup(const StringRef &Name) const {
return result;
}
+TypeSymbolTable::iterator TypeSymbolTable::find(const StringRef &Name) {
+ sys::SmartScopedReader<true> Reader(*TypeSymbolTableLock);
+ return tmap.find(Name);
+}
+
+TypeSymbolTable::const_iterator
+TypeSymbolTable::find(const StringRef &Name) const {
+ sys::SmartScopedReader<true> Reader(*TypeSymbolTableLock);
+ return tmap.find(Name);
+}
+
// remove - Remove a type from the symbol table...
Type* TypeSymbolTable::remove(iterator Entry) {
TypeSymbolTableLock->writer_acquire();