Skip to content

Commit 8c8b209

Browse files
Remove an extra map lookup
1 parent e1cef5b commit 8c8b209

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

src/tools/wasm-ctor-eval.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,12 @@ std::vector<std::unique_ptr<Module>> buildStubModules(Module& wasm) {
129129
Importable* importable =
130130
std::visit([](auto* i) -> Importable* { return i; }, import);
131131

132-
Module* module = nullptr;
133-
if (auto it = modules.find(importable->module); it != modules.end()) {
134-
module = it->second.get();
135-
} else {
136-
auto [inserted, _] =
137-
modules.emplace(importable->module, std::make_unique<Module>());
138-
module = inserted->second.get();
139-
module->name = importable->module;
132+
auto [it, inserted] = modules.try_emplace(importable->module, nullptr);
133+
if (inserted) {
134+
it->second = std::make_unique<Module>();
135+
it->second->name = importable->module;
140136
}
137+
Module* module = it->second.get();
141138

142139
struct Visitor {
143140
Module* module;

0 commit comments

Comments
 (0)