Skip to content

Commit

Permalink
Avoid doing lookup in map twice.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kasper Peeters committed Nov 7, 2024
1 parent 21a44e6 commit 7720402
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/algorithms/substitute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -507,15 +507,16 @@ bool substitute::Rules::is_present(Ex& rules) const

try {
std::weak_ptr<Ex> rules_ptr = rules.shared_from_this();
bool rule_found = (properties.find(rules_ptr) != properties.end());
auto rule_it = properties.find(rules_ptr);
bool rule_found = (rule_it != properties.end());
if (!rule_found) return false;

// rules should have l_checkpointed set
bool rule_unchanged = (rules.state() == result_t::l_cached);

// If rule has been changed, erase it.
if (!rule_unchanged) {
properties.erase(rules_ptr);
properties.erase(rules_it);
return false;
}
else {
Expand Down

0 comments on commit 7720402

Please sign in to comment.