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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232517 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCContext.h
lib/MC/MCContext.cpp

index 20fad95d3aec74a3c9b877ab087243795725649a..734103d5a6770d22cdefb4fb0bccfe64f639665d 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 608d958fc8eb1115d04f98d6b8778f373b51bb97..b0e7cf50d6920852247da5d4f4088bfa5590615a 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;