From d7c546c9352be6914a055e6ab4784d8a8b22b331 Mon Sep 17 00:00:00 2001 From: Yaron Keren Date: Tue, 17 Mar 2015 18:55:30 +0000 Subject: [PATCH] Remove LookupSymbol(StringRef) and optimize LookupSymbol(Twine). Same as MakeArgString in r232465, keep only LookupSymbol(Twine) while making sure it handles the StringRef like cases efficiently using twine::toStringRef. llvm-svn: 232517 --- llvm/include/llvm/MC/MCContext.h | 1 - llvm/lib/MC/MCContext.cpp | 10 +++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h index 20fad95..734103d 100644 --- a/llvm/include/llvm/MC/MCContext.h +++ b/llvm/include/llvm/MC/MCContext.h @@ -236,7 +236,6 @@ namespace llvm { MCSymbol *getOrCreateFrameAllocSymbol(StringRef FuncName, unsigned Idx); /// Get the symbol for \p Name, or null. - MCSymbol *LookupSymbol(StringRef Name) const; MCSymbol *LookupSymbol(const Twine &Name) const; /// getSymbols - Get a reference for the symbol table for clients that diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 608d958..b0e7cf5 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -219,14 +219,10 @@ MCSymbol *MCContext::GetDirectionalLocalSymbol(unsigned LocalLabelVal, return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance); } -MCSymbol *MCContext::LookupSymbol(StringRef Name) const { - return Symbols.lookup(Name); -} - MCSymbol *MCContext::LookupSymbol(const Twine &Name) const { SmallString<128> NameSV; - Name.toVector(NameSV); - return LookupSymbol(NameSV.str()); + StringRef NameRef = Name.toStringRef(NameSV); + return Symbols.lookup(NameRef); } //===----------------------------------------------------------------------===// @@ -249,7 +245,7 @@ MCContext::getMachOSection(StringRef Segment, StringRef Section, Name += Section; // Do the lookup, if we have a hit, return it. - const MCSectionMachO *&Entry = MachOUniquingMap[Name.str()]; + const MCSectionMachO *&Entry = MachOUniquingMap[Name]; if (Entry) return Entry; -- 2.7.4