Skip to content

Commit 66aa00e

Browse files
karkhazDegiorgio
authored andcommitted
Remove string lookups from goto_symext main loop
Lookups into goto_symext's options member have been replaced by accesses to instance members that are initialized from the optionst reference by goto_symext's constructor. This commit fixes diffblue#2050.
1 parent cfb5f34 commit 66aa00e

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/goto-symex/goto_symex.h

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class goto_symext
5656
path_storaget &path_storage)
5757
: should_pause_symex(false),
5858
options(options),
59+
max_depth(options.get_unsigned_int_option("depth")),
60+
doing_path_exploration(options.is_set("paths")),
5961
total_vccs(0),
6062
remaining_vccs(0),
6163
constant_propagation(true),
@@ -197,6 +199,9 @@ class goto_symext
197199

198200
const optionst &options;
199201

202+
const unsigned max_depth;
203+
const bool doing_path_exploration;
204+
200205
public:
201206
// these bypass the target maps
202207
virtual void symex_step_goto(statet &, bool taken);

src/goto-symex/symex_goto.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void goto_symext::symex_goto(statet &state)
114114
(simpl_state_guard.is_true() ||
115115
// or there is another block, but we're doing path exploration so
116116
// we're going to skip over it for now and return to it later.
117-
options.get_bool_option("paths")))
117+
doing_path_exploration))
118118
{
119119
DATA_INVARIANT(
120120
instruction.targets.size() > 0,
@@ -181,7 +181,7 @@ void goto_symext::symex_goto(statet &state)
181181
log.debug() << "Resuming from next instruction '"
182182
<< state_pc->source_location << "'" << log.eom;
183183
}
184-
else if(options.get_bool_option("paths"))
184+
else if(doing_path_exploration)
185185
{
186186
// We should save both the instruction after this goto, and the target of
187187
// the goto.

src/goto-symex/symex_main.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,13 @@ void goto_symext::symex_step(
308308

309309
const goto_programt::instructiont &instruction=*state.source.pc;
310310

311-
if(!options.get_bool_option("paths"))
311+
if(!doing_path_exploration)
312312
merge_gotos(state);
313313

314314
// depth exceeded?
315-
{
316-
unsigned max_depth=options.get_unsigned_int_option("depth");
317-
if(max_depth!=0 && state.depth>max_depth)
318-
state.guard.add(false_exprt());
319-
state.depth++;
320-
}
315+
if(max_depth != 0 && state.depth > max_depth)
316+
state.guard.add(false_exprt());
317+
state.depth++;
321318

322319
// actually do instruction
323320
switch(instruction.type)

0 commit comments

Comments
 (0)