[llvm-commits] [llvm] r79492 - in /llvm/trunk: include/llvm/ADT/Twine.h lib/VMCore/Value.cpp

Daniel Dunbar daniel at zuster.org
Wed Aug 19 16:37:24 PDT 2009


Author: ddunbar
Date: Wed Aug 19 18:37:23 2009
New Revision: 79492

URL: http://llvm.org/viewvc/llvm-project?rev=79492&view=rev
Log:
Add a fast path for setName("") on an unnamed value.

Modified:
    llvm/trunk/include/llvm/ADT/Twine.h
    llvm/trunk/lib/VMCore/Value.cpp

Modified: llvm/trunk/include/llvm/ADT/Twine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Twine.h?rev=79492&r1=79491&r2=79492&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/Twine.h (original)
+++ llvm/trunk/include/llvm/ADT/Twine.h Wed Aug 19 18:37:23 2009
@@ -321,6 +321,16 @@
     }
 
     /// @}
+    /// @name Predicate Operations
+    /// @{
+
+    /// isTriviallyEmpty - Check if this twine is trivially empty; a false
+    /// return value does not necessarily mean the twine is empty.
+    bool isTriviallyEmpty() const {
+      return isNullary();
+    }
+
+    /// @}
     /// @name String Operations
     /// @{
 

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

==============================================================================
--- llvm/trunk/lib/VMCore/Value.cpp (original)
+++ llvm/trunk/lib/VMCore/Value.cpp Wed Aug 19 18:37:23 2009
@@ -171,6 +171,10 @@
 }
 
 void Value::setName(const Twine &NewName) {
+  // Fast path for common IRBuilder case of setName("") when there is no name.
+  if (NewName.isTriviallyEmpty() && !hasName())
+    return;
+
   SmallString<256> NameData;
   NewName.toVector(NameData);
 





More information about the llvm-commits mailing list