Skip to content

Commit

Permalink
programmemory.cpp: avoid unnecessary infer() calls in `Executor::ex…
Browse files Browse the repository at this point in the history
…ecuteimpl()` (#6629)

`infer()` will exit early if any of the list of given values is empty.
so there is no need to call it (and copy the values with the call) if we
know that beforehand.
  • Loading branch information
firewave committed Jul 22, 2024
1 parent 84ddcfb commit fe1459d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/programmemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1506,13 +1506,13 @@ namespace {
if (!lhs.isUninitValue() && !rhs.isUninitValue())
r = evaluate(expr->str(), lhs, rhs);
if (expr->isComparisonOp() && (r.isUninitValue() || r.isImpossible())) {
if (rhs.isIntValue()) {
if (rhs.isIntValue() && !expr->astOperand1()->values().empty()) {
std::vector<ValueFlow::Value> result =
infer(ValueFlow::makeIntegralInferModel(), expr->str(), expr->astOperand1()->values(), {std::move(rhs)});
if (!result.empty() && result.front().isKnown())
return result.front();
}
if (lhs.isIntValue()) {
if (lhs.isIntValue() && !expr->astOperand2()->values().empty()) {
std::vector<ValueFlow::Value> result =
infer(ValueFlow::makeIntegralInferModel(), expr->str(), {std::move(lhs)}, expr->astOperand2()->values());
if (!result.empty() && result.front().isKnown())
Expand Down

0 comments on commit fe1459d

Please sign in to comment.