[dsymutil] Avoid calling getStringTableData() for each symbol. NFC.
authorFrederic Riss <friss@apple.com>
Tue, 16 Dec 2014 20:21:34 +0000 (20:21 +0000)
committerFrederic Riss <friss@apple.com>
Tue, 16 Dec 2014 20:21:34 +0000 (20:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224360 91177308-0d34-0410-b5e6-96231b3b80d8

tools/dsymutil/MachODebugMapParser.cpp

index 9a5e5453d5be1bbb2a902cd455a87ac7f86b7c62..c67e90c64eb486bfb6f0e97f0366460c504fcf5d 100644 (file)
@@ -36,6 +36,7 @@ private:
   object::OwningBinary<object::MachOObjectFile> MainOwningBinary;
   /// Map of the binary symbol addresses.
   StringMap<uint64_t> MainBinarySymbolAddresses;
+  StringRef MainBinaryStrings;
   /// The constructed DebugMap.
   std::unique_ptr<DebugMap> Result;
 
@@ -121,6 +122,7 @@ ErrorOr<std::unique_ptr<DebugMap>> MachODebugMapParser::parse() {
   loadMainBinarySymbols();
   Result = make_unique<DebugMap>();
   const auto &MainBinary = *MainOwningBinary.getBinary();
+  MainBinaryStrings = MainBinary.getStringTableData();
   for (const SymbolRef &Symbol : MainBinary.symbols()) {
     const DataRefImpl &DRI = Symbol.getRawDataRefImpl();
     if (MainBinary.is64Bit())
@@ -142,8 +144,7 @@ void MachODebugMapParser::handleStabSymbolTableEntry(uint32_t StringIndex,
   if (!(Type & MachO::N_STAB))
     return;
 
-  const MachOObjectFile &MachOBinary = *MainOwningBinary.getBinary();
-  const char *Name = &MachOBinary.getStringTableData().data()[StringIndex];
+  const char *Name = &MainBinaryStrings.data()[StringIndex];
 
   // An N_OSO entry represents the start of a new object file description.
   if (Type == MachO::N_OSO)