diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-04-09 11:26:27 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-04-09 11:26:27 +0000 |
commit | c18214a6e0a22ffa6886c70dbd6176ac9e91c847 (patch) | |
tree | fc1a9439337cf008919eee538a68f0eda7b21fb3 /lib | |
parent | cc513e1cf19bbdab83c5336455196e0e91d57f32 (diff) | |
download | external_llvm-c18214a6e0a22ffa6886c70dbd6176ac9e91c847.zip external_llvm-c18214a6e0a22ffa6886c70dbd6176ac9e91c847.tar.gz external_llvm-c18214a6e0a22ffa6886c70dbd6176ac9e91c847.tar.bz2 |
Don't store Twine temporaries, it's not safe.
And don't append the name over and over again in the loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129210 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MC/MCContext.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index 7c68713..af8cd8e 100644 --- a/lib/MC/MCContext.cpp +++ b/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); } |