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.
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.
// 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();