add a setName variant that takes a null-terminated string. This can be
authorChris Lattner <sabre@nondot.org>
Tue, 13 Feb 2007 07:53:34 +0000 (07:53 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 13 Feb 2007 07:53:34 +0000 (07:53 +0000)
used to avoid std::string allocations in common cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34232 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Value.h
lib/VMCore/Value.cpp

index be751d5f6323249eb321781eee70c95473009b5f..fac596b415c9b304933d3f4705cdd84bda02095a 100644 (file)
@@ -92,6 +92,8 @@ public:
 
   void setName(const std::string &name);
   void setName(const char *Name, unsigned NameLen);
+  void setName(const char *Name);  // Takes a null-terminated string.
+
   
   /// takeName - transfer the name from V to this value, setting V's name to
   /// empty.  It is an error to call V->takeName(V). 
index ee6f94ad386aa624bfb2009995ba71386c55667c..c7af93135986b230863a453f37c124a8f52f0b7c 100644 (file)
@@ -122,6 +122,10 @@ void Value::setName(const std::string &name) {
   setName(&name[0], name.size());
 }
 
+void Value::setName(const char *Name) {
+  setName(Name, Name ? strlen(Name) : 0);
+}
+
 void Value::setName(const char *NameStr, unsigned NameLen) {
   if (NameLen == 0 && !hasName()) return;
   if (getType() != Type::VoidTy && "Cannot assign a name to void values!");