summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCContext.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-04-09 11:26:27 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-04-09 11:26:27 +0000
commit2b6c96b43d3355ac4bff9498d7ec219f00e32323 (patch)
tree33f7e24982cf026b78bb022e20a9c636817e3a6d /llvm/lib/MC/MCContext.cpp
parent2792f2b86b8aca24b2aae8a782971ef0dc461e45 (diff)
downloadbcm5719-llvm-2b6c96b43d3355ac4bff9498d7ec219f00e32323.tar.gz
bcm5719-llvm-2b6c96b43d3355ac4bff9498d7ec219f00e32323.zip
Don't store Twine temporaries, it's not safe.
And don't append the name over and over again in the loop. llvm-svn: 129210
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r--llvm/lib/MC/MCContext.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 7c687135fc6..af8cd8eb141 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -85,12 +85,11 @@ MCSymbol *MCContext::CreateSymbol(StringRef Name) {
StringMapEntry<bool> *NameEntry = &UsedNames.GetOrCreateValue(Name);
if (NameEntry->getValue()) {
assert(isTemporary && "Cannot rename non temporary symbols");
- SmallString<128> NewName;
+ SmallString<128> NewName = Name;
do {
- Twine T = Name + Twine(NextUniqueID++);
- T.toVector(NewName);
- StringRef foo = NewName;
- NameEntry = &UsedNames.GetOrCreateValue(foo);
+ NewName.resize(Name.size());
+ raw_svector_ostream(NewName) << NextUniqueID++;
+ NameEntry = &UsedNames.GetOrCreateValue(NewName);
} while (NameEntry->getValue());
}
NameEntry->setValue(true);
@@ -110,9 +109,8 @@ MCSymbol *MCContext::GetOrCreateSymbol(const Twine &Name) {
MCSymbol *MCContext::CreateTempSymbol() {
SmallString<128> NameSV;
- Twine Name = Twine(MAI.getPrivateGlobalPrefix()) + "tmp" +
- Twine(NextUniqueID++);
- Name.toVector(NameSV);
+ raw_svector_ostream(NameSV)
+ << MAI.getPrivateGlobalPrefix() << "tmp" << NextUniqueID++;
return CreateSymbol(NameSV);
}
OpenPOWER on IntegriCloud