[llvm] r219233 - Optimize COFFObjectFile::sectionContainsSymbol a bit.

Rafael Espindola rafael.espindola at gmail.com
Tue Oct 7 13:42:47 PDT 2014


Author: rafael
Date: Tue Oct  7 15:42:47 2014
New Revision: 219233

URL: http://llvm.org/viewvc/llvm-project?rev=219233&view=rev
Log:
Optimize COFFObjectFile::sectionContainsSymbol a bit.

There is no need to compute the coff_section of the symbol just to compare the
pointer.

Inspired by the ELF implementation.

Modified:
    llvm/trunk/lib/Object/COFFObjectFile.cpp

Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=219233&r1=219232&r2=219233&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Tue Oct  7 15:42:47 2014
@@ -347,13 +347,8 @@ std::error_code COFFObjectFile::sectionC
                                                       bool &Result) const {
   const coff_section *Sec = toSec(SecRef);
   COFFSymbolRef Symb = getCOFFSymbol(SymbRef);
-  const coff_section *SymbSec = nullptr;
-  if (std::error_code EC = getSection(Symb.getSectionNumber(), SymbSec))
-    return EC;
-  if (SymbSec == Sec)
-    Result = true;
-  else
-    Result = false;
+  int32_t SecNumber = (Sec - SectionTable) + 1;
+  Result = SecNumber == Symb.getSectionNumber();
   return object_error::success;
 }
 





More information about the llvm-commits mailing list