Skip to content

Commit

Permalink
Return from get_diff by value
Browse files Browse the repository at this point in the history
  • Loading branch information
reuk committed Nov 1, 2017
1 parent 6833af6 commit a7afc6c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
3 changes: 1 addition & 2 deletions src/goto-diff/change_impact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ change_impactt::change_impactt(

void change_impactt::change_impact(const irep_idt &function)
{
unified_difft::goto_program_difft diff;
unified_diff.get_diff(function, diff);
unified_difft::goto_program_difft diff = unified_diff.get_diff(function);

if(diff.empty())
return;
Expand Down
23 changes: 12 additions & 11 deletions src/goto-diff/unified_diff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ unified_difft::unified_difft(
{
}

void unified_difft::get_diff(const irep_idt &function, goto_program_difft &dest)
const
unified_difft::goto_program_difft
unified_difft::get_diff(const irep_idt &function) const
{
dest.clear();

differences_mapt::const_iterator entry = differences_map_.find(function);
if(entry == differences_map_.end())
return;
return {};

goto_functionst::function_mapt::const_iterator old_fit =
old_goto_functions.function_map.find(function);
Expand All @@ -50,20 +48,21 @@ void unified_difft::get_diff(const irep_idt &function, goto_program_difft &dest)
new_fit == new_goto_functions.function_map.end() ? empty
: new_fit->second.body;

get_diff(old_goto_program, new_goto_program, entry->second, dest);
return get_diff(old_goto_program, new_goto_program, entry->second);
}

void unified_difft::get_diff(
unified_difft::goto_program_difft unified_difft::get_diff(
const goto_programt &old_goto_program,
const goto_programt &new_goto_program,
const differencest &differences,
goto_program_difft &dest) const
const differencest &differences) const
{
goto_programt::instructionst::const_iterator old_it =
old_goto_program.instructions.begin();
goto_programt::instructionst::const_iterator new_it =
new_goto_program.instructions.begin();

goto_program_difft dest;

for(differencest::const_reverse_iterator rit = differences.rbegin();
rit != differences.rend();
++rit)
Expand All @@ -89,6 +88,8 @@ void unified_difft::get_diff(
break;
}
}

return dest;
}

void unified_difft::output_diff(
Expand All @@ -98,8 +99,8 @@ void unified_difft::output_diff(
const differencest &differences,
std::ostream &os) const
{
goto_program_difft diff;
get_diff(old_goto_program, new_goto_program, differences, diff);
goto_program_difft diff =
get_diff(old_goto_program, new_goto_program, differences);

bool has_diff = false;
for(const auto &d : diff)
Expand Down
7 changes: 3 additions & 4 deletions src/goto-diff/unified_diff.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class unified_difft
typedef std::list<std::pair<goto_programt::const_targett, differencet>>
goto_program_difft;

void get_diff(const irep_idt &function, goto_program_difft &dest) const;
goto_program_difft get_diff(const irep_idt &function) const;

const goto_functionst &old_goto_functions;
const namespacet ns_old;
Expand All @@ -67,11 +67,10 @@ class unified_difft
const goto_programt &new_goto_program,
differencest &differences) const;

void get_diff(
goto_program_difft get_diff(
const goto_programt &old_goto_program,
const goto_programt &new_goto_program,
const differencest &differences,
goto_program_difft &dest) const;
const differencest &differences) const;

void output_diff(
const irep_idt &identifier,
Expand Down

0 comments on commit a7afc6c

Please sign in to comment.