Skip to content

Commit b3b88e5

Browse files
committed
valueflow.cpp: bail out early in LifetimeStore::byVal() to avoid unnecessary object creation [skip ci]
1 parent 07ef476 commit b3b88e5

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

lib/valueflow.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,19 +2135,20 @@ struct LifetimeStore {
21352135
for (const ValueFlow::LifetimeToken& lt : ValueFlow::getLifetimeTokens(argtok, settings)) {
21362136
if (!settings.certainty.isEnabled(Certainty::inconclusive) && lt.inconclusive)
21372137
continue;
2138+
2139+
const Variable* var = lt.token->variable();
2140+
if (!var || !var->isArgument())
2141+
continue;
2142+
21382143
ValueFlow::Value value;
21392144
value.valueType = ValueFlow::Value::ValueType::LIFETIME;
21402145
value.tokvalue = lt.token;
21412146
value.capturetok = argtok;
21422147
value.errorPath = er;
21432148
value.lifetimeKind = type;
21442149
value.setInconclusive(inconclusive || lt.inconclusive);
2145-
const Variable* var = lt.token->variable();
2146-
if (var && var->isArgument()) {
2147-
value.lifetimeScope = ValueFlow::Value::LifetimeScope::Argument;
2148-
} else {
2149-
continue;
2150-
}
2150+
value.lifetimeScope = ValueFlow::Value::LifetimeScope::Argument;
2151+
21512152
// Don't add the value a second time
21522153
if (std::find(tok->values().cbegin(), tok->values().cend(), value) != tok->values().cend())
21532154
continue;

0 commit comments

Comments
 (0)