[llvm-commits] [llvm] r77102 - /llvm/trunk/lib/VMCore/Value.cpp

Daniel Dunbar daniel at zuster.org
Sat Jul 25 17:42:34 PDT 2009


Author: ddunbar
Date: Sat Jul 25 19:42:33 2009
New Revision: 77102

URL: http://llvm.org/viewvc/llvm-project?rev=77102&view=rev
Log:
Simplify.

Modified:
    llvm/trunk/lib/VMCore/Value.cpp

Modified: llvm/trunk/lib/VMCore/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=77102&r1=77101&r2=77102&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Value.cpp (original)
+++ llvm/trunk/lib/VMCore/Value.cpp Sat Jul 25 19:42:33 2009
@@ -177,7 +177,10 @@
   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 @@
       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 @@
   // 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();





More information about the llvm-commits mailing list