Remove LookupSymbol(StringRef) and optimize LookupSymbol(Twine).
authorYaron Keren <yaron.keren@gmail.com>
Tue, 17 Mar 2015 18:55:30 +0000 (18:55 +0000)
committerYaron Keren <yaron.keren@gmail.com>
Tue, 17 Mar 2015 18:55:30 +0000 (18:55 +0000)
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
llvm/lib/MC/MCContext.cpp

index 20fad95..734103d 100644 (file)
@@ -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
index 608d958..b0e7cf5 100644 (file)
@@ -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;