aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-07 05:22:49 +0000
committerChris Lattner <sabre@nondot.org>2007-02-07 05:22:49 +0000
commitf5111552c24d0dcea3b7b1a9c0d2c1f338191891 (patch)
treed06e9b67a792f87015f80e31984fa7c32ab05a46 /lib
parent670ccfe6a473c3fdab6bc958ad9fc74ef54031d3 (diff)
Eliminate a bunch of work from ValueSymbolTable::insert for the common case
where a symbol name doesn't conflict. This speeds up bc reading 16% on 176.gcc! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33981 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/ValueSymbolTable.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/VMCore/ValueSymbolTable.cpp b/lib/VMCore/ValueSymbolTable.cpp
index 51197b6bf3..6bd5b0c49c 100644
--- a/lib/VMCore/ValueSymbolTable.cpp
+++ b/lib/VMCore/ValueSymbolTable.cpp
@@ -81,7 +81,13 @@ void ValueSymbolTable::insert(Value* V) {
assert(V && "Can't insert null Value into symbol table!");
assert(V->hasName() && "Can't insert nameless Value into symbol table");
- // Check to see if there is a naming conflict. If so, rename this value
+ // Try inserting the name, assuming it won't conflict.
+ if (vmap.insert(make_pair(V->Name, V)).second) {
+ DOUT << " Inserted value: " << V->Name << ": " << *V << "\n";
+ return;
+ }
+
+ // Otherwise, there is a naming conflict. Rename this value.
std::string UniqueName = getUniqueName(V->getName());
DEBUG(DOUT << " Inserting value: " << UniqueName << ": " << *V << "\n");