From fe1459d4776dfefc7ca2a5a1d0177d71d209802c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Mon, 22 Jul 2024 11:22:36 +0200 Subject: [PATCH] programmemory.cpp: avoid unnecessary `infer()` calls in `Executor::executeimpl()` (#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. --- lib/programmemory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/programmemory.cpp b/lib/programmemory.cpp index da7770f65ce..2619ed876b2 100644 --- a/lib/programmemory.cpp +++ b/lib/programmemory.cpp @@ -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 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 result = infer(ValueFlow::makeIntegralInferModel(), expr->str(), {std::move(lhs)}, expr->astOperand2()->values()); if (!result.empty() && result.front().isKnown())