Skip to content

Commit fe1459d

Browse files
authored
programmemory.cpp: avoid unnecessary infer() calls in Executor::executeimpl() (danmar#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.
1 parent 84ddcfb commit fe1459d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/programmemory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,13 +1506,13 @@ namespace {
15061506
if (!lhs.isUninitValue() && !rhs.isUninitValue())
15071507
r = evaluate(expr->str(), lhs, rhs);
15081508
if (expr->isComparisonOp() && (r.isUninitValue() || r.isImpossible())) {
1509-
if (rhs.isIntValue()) {
1509+
if (rhs.isIntValue() && !expr->astOperand1()->values().empty()) {
15101510
std::vector<ValueFlow::Value> result =
15111511
infer(ValueFlow::makeIntegralInferModel(), expr->str(), expr->astOperand1()->values(), {std::move(rhs)});
15121512
if (!result.empty() && result.front().isKnown())
15131513
return result.front();
15141514
}
1515-
if (lhs.isIntValue()) {
1515+
if (lhs.isIntValue() && !expr->astOperand2()->values().empty()) {
15161516
std::vector<ValueFlow::Value> result =
15171517
infer(ValueFlow::makeIntegralInferModel(), expr->str(), {std::move(lhs)}, expr->astOperand2()->values());
15181518
if (!result.empty() && result.front().isKnown())

0 commit comments

Comments
 (0)