summaryrefslogtreecommitdiff
path: root/lld/ELF/InputSection.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2018-03-28 03:20:18 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2018-03-28 03:20:18 +0000
commitd878407106959663499f7d324b87f2dfc810b371 (patch)
tree0f9f07937eb076c9237380fab9a71241fdd70d3a /lld/ELF/InputSection.cpp
parent9ce806de0015d1659b75e12ff0a8fdf4c0834c49 (diff)
Initialize OffsetMap in a known location.
This is a small optimization and avoids the need to use call_once.
Diffstat (limited to 'lld/ELF/InputSection.cpp')
-rw-r--r--lld/ELF/InputSection.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 7b1342eca53..49426e879fe 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -958,13 +958,6 @@ uint64_t MergeInputSection::getOffset(uint64_t Offset) const {
if (!Live)
return 0;
- // Initialize OffsetMap lazily.
- llvm::call_once(InitOffsetMap, [&] {
- OffsetMap.reserve(Pieces.size());
- for (size_t I = 0; I < Pieces.size(); ++I)
- OffsetMap[Pieces[I].InputOff] = I;
- });
-
// Find a string starting at a given offset.
auto It = OffsetMap.find(Offset);
if (It != OffsetMap.end())
@@ -980,6 +973,12 @@ uint64_t MergeInputSection::getOffset(uint64_t Offset) const {
return Piece.OutputOff + Addend;
}
+void MergeInputSection::initOffsetMap() {
+ OffsetMap.reserve(Pieces.size());
+ for (size_t I = 0; I < Pieces.size(); ++I)
+ OffsetMap[Pieces[I].InputOff] = I;
+}
+
template InputSection::InputSection(ObjFile<ELF32LE> &, const ELF32LE::Shdr &,
StringRef);
template InputSection::InputSection(ObjFile<ELF32BE> &, const ELF32BE::Shdr &,