MCPcopy Create free account
hub / github.com/KDE/kdiff3 / calcDiff3LineListUsingBC

Method calcDiff3LineListUsingBC

src/diff.cpp:265–514  ·  view source on GitHub ↗

Third step

Source from the content-addressed store, hash-verified

263
264// Third step
265void Diff3LineList::calcDiff3LineListUsingBC(const DiffList* pDiffListBC)
266{
267 ////////////////
268 // Now improve the position of data from C using pDiffListBC
269 // If a line from C equals a line from A then it is in the
270 // same Diff3Line already.
271 // If a line from C equals a line from B but not A, this
272 // information will be used here.
273
274 Diff3LineList::iterator i3b = begin();
275 Diff3LineList::iterator i3c = begin();
276 LineRef lineB = 0;
277 LineRef lineC = 0;
278
279 for(Diff d: *pDiffListBC)
280 {
281 while(d.numberOfEquals() > 0)
282 {
283 Diff3Line d3l;
284 // Find the corresponding lineB and lineC
285 while(i3b != end() && i3b->getLineB() != lineB)
286 ++i3b;
287
288 while(i3c != end() && i3c->getLineC() != lineC)
289 ++i3c;
290
291 assert(i3b != end());
292 assert(i3c != end());
293
294 if(i3b == i3c)
295 {
296 assert(i3b->getLineC() == lineC);
297 i3b->bBEqC = true;
298 }
299 else
300 {
301 // Is it possible to move this line up?
302 // Test if no other B's are used between i3c and i3b
303
304 // First test which is before: i3c or i3b ?
305 Diff3LineList::iterator i3c1 = i3c;
306 Diff3LineList::iterator i3b1 = i3b;
307 while(i3c1 != i3b && i3b1 != i3c)
308 {
309 assert(i3b1 != end() || i3c1 != end());
310 if(i3c1 != end()) ++i3c1;
311 if(i3b1 != end()) ++i3b1;
312 }
313
314 if(i3c1 == i3b && !i3b->isEqualAB()) // i3c before i3b
315 {
316 Diff3LineList::iterator i3 = i3c;
317 quint32 nofDisturbingLines = 0;
318 while(i3 != i3b && i3 != end())
319 {
320 if(i3->getLineB().isValid())
321 ++nofDisturbingLines;
322 ++i3;

Callers 2

determineFileAlignmentFunction · 0.80
mainInitMethod · 0.80

Calls 15

numberOfEqualsMethod · 0.80
getLineBMethod · 0.80
getLineCMethod · 0.80
getLineAMethod · 0.80
setLineBMethod · 0.80
setLineAMethod · 0.80
setLineCMethod · 0.80
adjustNumberOfEqualsMethod · 0.80
diff1Method · 0.80
adjustDiff1Method · 0.80
diff2Method · 0.80
adjustDiff2Method · 0.80

Tested by 1

determineFileAlignmentFunction · 0.64