Skip to content

Commit 65330e2

Browse files
[llvm-readobj] Avoid repeated hash lookups (NFC) (#129657)
1 parent 9372d1d commit 65330e2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/tools/llvm-readobj/COFFDumper.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,11 @@ void COFFDumper::cacheRelocations() {
645645
for (const SectionRef &S : Obj->sections()) {
646646
const coff_section *Section = Obj->getCOFFSection(S);
647647

648-
append_range(RelocMap[Section], S.relocations());
648+
auto &RM = RelocMap[Section];
649+
append_range(RM, S.relocations());
649650

650651
// Sort relocations by address.
651-
llvm::sort(RelocMap[Section], [](RelocationRef L, RelocationRef R) {
652+
llvm::sort(RM, [](RelocationRef L, RelocationRef R) {
652653
return L.getOffset() < R.getOffset();
653654
});
654655
}
@@ -1270,14 +1271,15 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName,
12701271
reportError(errorCodeToError(EC), Obj->getFileName());
12711272

12721273
W.printString("LinkageName", LinkageName);
1273-
if (FunctionLineTables.count(LinkageName) != 0) {
1274+
auto [It, Inserted] =
1275+
FunctionLineTables.try_emplace(LinkageName, Contents);
1276+
if (!Inserted) {
12741277
// Saw debug info for this function already?
12751278
reportError(errorCodeToError(object_error::parse_failed),
12761279
Obj->getFileName());
12771280
return;
12781281
}
12791282

1280-
FunctionLineTables[LinkageName] = Contents;
12811283
FunctionNames.push_back(LinkageName);
12821284
break;
12831285
}

0 commit comments

Comments
 (0)