Skip to content

Commit 5057c57

Browse files
authored
Merge pull request diffblue#1557 from janmroczkowski/janmroczkowski/further-improvements-to-unified_difft
Further improvements to unified_difft
2 parents 5e067bf + 2648cbb commit 5057c57

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/goto-diff/unified_diff.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ unified_difft::get_diff(const irep_idt &function) const
5454
unified_difft::goto_program_difft unified_difft::get_diff(
5555
const goto_programt &old_goto_program,
5656
const goto_programt &new_goto_program,
57-
const differencest &differences) const
57+
const differencest &differences)
5858
{
5959
goto_programt::instructionst::const_iterator old_it =
6060
old_goto_program.instructions.begin();
@@ -144,15 +144,15 @@ void unified_difft::output_diff(
144144
}
145145
}
146146

147-
void unified_difft::lcss(
147+
unified_difft::differencest unified_difft::lcss(
148148
const irep_idt &identifier,
149149
const goto_programt &old_goto_program,
150-
const goto_programt &new_goto_program,
151-
differencest &differences) const
150+
const goto_programt &new_goto_program)
152151
{
153152
std::size_t old_count = old_goto_program.instructions.size();
154153
std::size_t new_count = new_goto_program.instructions.size();
155154

155+
differencest differences;
156156
differences.reserve(old_count + new_count);
157157

158158
// skip common prefix
@@ -200,7 +200,7 @@ void unified_difft::lcss(
200200
// the common tail
201201

202202
if(old_count == 0 && new_count == 0)
203-
return;
203+
return differences;
204204

205205
// apply longest common subsequence (LCSS)
206206
typedef std::vector<std::vector<std::size_t>> lcss_matrixt;
@@ -293,6 +293,8 @@ void unified_difft::lcss(
293293
// add common prefix (if any)
294294
for(; old_it != old_goto_program.instructions.begin(); --old_it)
295295
differences.push_back(differencet::SAME);
296+
297+
return differences;
296298
}
297299

298300
void unified_difft::unified_diff(
@@ -315,7 +317,7 @@ void unified_difft::unified_diff(
315317
new_goto_program.instructions.size(), differencet::NEW);
316318
}
317319
else
318-
lcss(identifier, old_goto_program, new_goto_program, differences);
320+
differences=lcss(identifier, old_goto_program, new_goto_program);
319321
}
320322

321323
bool unified_difft::operator()()

src/goto-diff/unified_diff.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,15 @@ class unified_difft
6161
const goto_programt &old_goto_program,
6262
const goto_programt &new_goto_program);
6363

64-
void lcss(
64+
static differencest lcss(
6565
const irep_idt &identifier,
6666
const goto_programt &old_goto_program,
67-
const goto_programt &new_goto_program,
68-
differencest &differences) const;
67+
const goto_programt &new_goto_program);
6968

70-
goto_program_difft get_diff(
69+
static goto_program_difft get_diff(
7170
const goto_programt &old_goto_program,
7271
const goto_programt &new_goto_program,
73-
const differencest &differences) const;
72+
const differencest &differences);
7473

7574
void output_diff(
7675
const irep_idt &identifier,

0 commit comments

Comments
 (0)