Skip to content

Commit 28759bc

Browse files
committed
Refactor symbol lookup
The previous implementation contained 2x "not" operations. By appling De Morgan's laws these operations can be dispensed with and the code is thus made more readable.
1 parent 6c33e07 commit 28759bc

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/solvers/smt2_incremental/smt2_incremental_decision_procedure.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,21 @@ void smt2_incremental_decision_proceduret::define_dependent_functions(
6767
{
6868
const irep_idt &identifier = symbol_expr->get_identifier();
6969
const symbolt *symbol = nullptr;
70-
if(!ns.lookup(identifier, symbol) && !symbol->value.is_nil())
70+
if(ns.lookup(identifier, symbol) || symbol->value.is_nil())
7171
{
72-
if(dependencies_needed(symbol->value))
73-
continue;
74-
const smt_define_function_commandt function{
75-
symbol->name, {}, convert_expr_to_smt(symbol->value)};
72+
const smt_declare_function_commandt function{
73+
smt_identifier_termt(
74+
identifier, convert_type_to_smt_sort(symbol_expr->type())),
75+
{}};
7676
expression_identifiers.emplace(*symbol_expr, function.identifier());
7777
solver_process->send(function);
7878
}
7979
else
8080
{
81-
const smt_declare_function_commandt function{
82-
smt_identifier_termt(
83-
identifier, convert_type_to_smt_sort(symbol_expr->type())),
84-
{}};
81+
if(dependencies_needed(symbol->value))
82+
continue;
83+
const smt_define_function_commandt function{
84+
symbol->name, {}, convert_expr_to_smt(symbol->value)};
8585
expression_identifiers.emplace(*symbol_expr, function.identifier());
8686
solver_process->send(function);
8787
}

0 commit comments

Comments
 (0)