diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-26 00:42:33 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-26 00:42:33 +0000 |
commit | ceb54d4bd5fec4a7c67929d8b339e91720812bce (patch) | |
tree | fe7c90ca6181df0c56143ce79e4c439748501fb9 /lib/VMCore/Value.cpp | |
parent | c1cd72e05f3324eb2d7f1db44848e11541a8fa5a (diff) | |
download | external_llvm-ceb54d4bd5fec4a7c67929d8b339e91720812bce.zip external_llvm-ceb54d4bd5fec4a7c67929d8b339e91720812bce.tar.gz external_llvm-ceb54d4bd5fec4a7c67929d8b339e91720812bce.tar.bz2 |
Simplify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77102 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Value.cpp')
-rw-r--r-- | lib/VMCore/Value.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index 6157dd5..67cd11a 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -177,7 +177,10 @@ void Value::setName(const Twine &NewName) { const char *NameStr = NameData.data(); unsigned NameLen = NameData.size(); - if (NameLen == 0 && !hasName()) return; + // Name isn't changing? + if (getName() == StringRef(NameStr, NameLen)) + return; + assert(getType() != Type::VoidTy && "Cannot assign a name to void values!"); // Get the symbol table to update for this object. @@ -193,13 +196,8 @@ void Value::setName(const Twine &NewName) { return; } - if (Name) { - // Name isn't changing? - if (NameLen == Name->getKeyLength() && - !memcmp(Name->getKeyData(), NameStr, NameLen)) - return; + if (Name) Name->Destroy(); - } // NOTE: Could optimize for the case the name is shrinking to not deallocate // then reallocated. @@ -213,11 +211,6 @@ void Value::setName(const Twine &NewName) { // NOTE: Could optimize for the case the name is shrinking to not deallocate // then reallocated. if (hasName()) { - // Name isn't changing? - if (NameLen == Name->getKeyLength() && - !memcmp(Name->getKeyData(), NameStr, NameLen)) - return; - // Remove old name. ST->removeValueName(Name); Name->Destroy(); |