Skip to content

Commit 3919793

Browse files
[WebAssembly] Avoid repeated hash lookups (NFC) (#129469)
1 parent f3d4d11 commit 3919793

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,15 +491,16 @@ static Value *getAddrSizeInt(Module *M, uint64_t C) {
491491
Function *
492492
WebAssemblyLowerEmscriptenEHSjLj::getFindMatchingCatch(Module &M,
493493
unsigned NumClauses) {
494-
if (FindMatchingCatches.count(NumClauses))
495-
return FindMatchingCatches[NumClauses];
494+
auto [It, Inserted] = FindMatchingCatches.try_emplace(NumClauses);
495+
if (!Inserted)
496+
return It->second;
496497
PointerType *Int8PtrTy = PointerType::getUnqual(M.getContext());
497498
SmallVector<Type *, 16> Args(NumClauses, Int8PtrTy);
498499
FunctionType *FTy = FunctionType::get(Int8PtrTy, Args, false);
499500
Function *F = getFunction(
500501
FTy, "__cxa_find_matching_catch_" + Twine(NumClauses + 2), &M);
501502
markAsImported(F);
502-
FindMatchingCatches[NumClauses] = F;
503+
It->second = F;
503504
return F;
504505
}
505506

0 commit comments

Comments
 (0)