aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/COFFObjectFile.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-10-07 20:42:47 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-10-07 20:42:47 +0000
commita92608657f7568ace836877c7f07883f4d7f9167 (patch)
tree08c28e57d3556d28879dfc83d85d8d4f57697398 /llvm/lib/Object/COFFObjectFile.cpp
parent5cbeb850fb8180ede6c098ce7f92a0a09951c32a (diff)
downloadllvm-a92608657f7568ace836877c7f07883f4d7f9167.zip
llvm-a92608657f7568ace836877c7f07883f4d7f9167.tar.gz
llvm-a92608657f7568ace836877c7f07883f4d7f9167.tar.bz2
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. llvm-svn: 219233
Diffstat (limited to 'llvm/lib/Object/COFFObjectFile.cpp')
-rw-r--r--llvm/lib/Object/COFFObjectFile.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp
index bd70157..6e1f683 100644
--- a/llvm/lib/Object/COFFObjectFile.cpp
+++ b/llvm/lib/Object/COFFObjectFile.cpp
@@ -347,13 +347,8 @@ std::error_code COFFObjectFile::sectionContainsSymbol(DataRefImpl SecRef,
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;
}