Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/goto-diff/unified_diff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ unified_difft::get_diff(const irep_idt &function) const
unified_difft::goto_program_difft unified_difft::get_diff(
const goto_programt &old_goto_program,
const goto_programt &new_goto_program,
const differencest &differences) const
const differencest &differences)
{
goto_programt::instructionst::const_iterator old_it =
old_goto_program.instructions.begin();
Expand Down Expand Up @@ -144,15 +144,15 @@ void unified_difft::output_diff(
}
}

void unified_difft::lcss(
unified_difft::differencest unified_difft::lcss(
const irep_idt &identifier,
const goto_programt &old_goto_program,
const goto_programt &new_goto_program,
differencest &differences) const
const goto_programt &new_goto_program)
{
std::size_t old_count = old_goto_program.instructions.size();
std::size_t new_count = new_goto_program.instructions.size();

differencest differences;
differences.reserve(old_count + new_count);

// skip common prefix
Expand Down Expand Up @@ -200,7 +200,7 @@ void unified_difft::lcss(
// the common tail

if(old_count == 0 && new_count == 0)
return;
return differences;

// apply longest common subsequence (LCSS)
typedef std::vector<std::vector<std::size_t>> lcss_matrixt;
Expand Down Expand Up @@ -293,6 +293,8 @@ void unified_difft::lcss(
// add common prefix (if any)
for(; old_it != old_goto_program.instructions.begin(); --old_it)
differences.push_back(differencet::SAME);

return differences;
}

void unified_difft::unified_diff(
Expand All @@ -315,7 +317,7 @@ void unified_difft::unified_diff(
new_goto_program.instructions.size(), differencet::NEW);
}
else
lcss(identifier, old_goto_program, new_goto_program, differences);
differences=lcss(identifier, old_goto_program, new_goto_program);
}

bool unified_difft::operator()()
Expand Down
9 changes: 4 additions & 5 deletions src/goto-diff/unified_diff.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,15 @@ class unified_difft
const goto_programt &old_goto_program,
const goto_programt &new_goto_program);

void lcss(
static differencest lcss(
const irep_idt &identifier,
const goto_programt &old_goto_program,
const goto_programt &new_goto_program,
differencest &differences) const;
const goto_programt &new_goto_program);

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

void output_diff(
const irep_idt &identifier,
Expand Down