Skip to content

Commit

Permalink
avoid duplicated evaluation in `ProgramMemoryState::removeModifiedVar…
Browse files Browse the repository at this point in the history
…s()` (#6628)

Co-authored-by: Paul Fultz II <[email protected]>
  • Loading branch information
firewave and pfultz2 committed Jul 26, 2024
1 parent dc3ec3f commit 8368943
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/programmemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,11 @@ void ProgramMemoryState::removeModifiedVars(const Token* tok)
{
const ProgramMemory& pm = state;
auto eval = [&](const Token* cond) -> std::vector<MathLib::bigint> {
if (conditionIsTrue(cond, pm, *settings))
ProgramMemory pm2 = pm;
auto result = execute(cond, pm2, *settings);
if (isTrue(result))
return {1};
if (conditionIsFalse(cond, pm, *settings))
if (isFalse(result))
return {0};
return {};
};
Expand Down

0 comments on commit 8368943

Please sign in to comment.