Skip to content

Commit 2648cbb

Browse files
author
janmroczkowski
committed
Make unified_difft::lcss return by value
1 parent 6e3a0b0 commit 2648cbb

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/goto-diff/unified_diff.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -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)
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

+2-3
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@ class unified_difft
6161
const goto_programt &old_goto_program,
6262
const goto_programt &new_goto_program);
6363

64-
static 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);
67+
const goto_programt &new_goto_program);
6968

7069
static goto_program_difft get_diff(
7170
const goto_programt &old_goto_program,

0 commit comments

Comments
 (0)