use iterator-based idiom for check-if-present-then-access

This commit is contained in:
Vern Paxson 2021-11-22 15:28:15 -08:00
parent 735d584d9f
commit 84423369b4
12 changed files with 86 additions and 59 deletions

View file

@ -154,8 +154,9 @@ void activate_bodies__CPP(const char* fn, const char* module, bool exported, Typ
continue;
// Add in the new body.
ASSERT(compiled_scripts.count(h) > 0);
auto cs = compiled_scripts[h];
auto csi = compiled_scripts.find(h);
ASSERT(csi != compiled_scripts.end());
auto cs = csi->second;
f->AddBody(cs.body, no_inits, num_params, cs.priority);
added_bodies[fn].insert(h);
@ -220,9 +221,10 @@ FuncValPtr lookup_func__CPP(string name, vector<p_hash_type> hashes, const TypeP
for ( auto h : hashes )
{
ASSERT(compiled_scripts.count(h) > 0);
auto cs = compiled_scripts.find(h);
ASSERT(cs != compiled_scripts.end());
const auto& f = compiled_scripts[h];
const auto& f = cs->second;
bodies.push_back(f.body);
priorities.push_back(f.priority);