MCPcopy Create free account
hub / github.com/WinMerge/winmerge / PopulateDiffs

Method PopulateDiffs

Src/stringdiffs.cpp:489–517  ·  view source on GitHub ↗

* @brief Populate m_pDiffs from m_wdiffs (combining adjacent diffs) * * Doing the combining of adjacent diffs here keeps some complexity out of BuildWordsArray. */

Source from the content-addressed store, hash-verified

487 * Doing the combining of adjacent diffs here keeps some complexity out of BuildWordsArray.
488 */
489void
490stringdiffs::PopulateDiffs()
491{
492 for (int i=0; i< (int)m_wdiffs.size(); ++i)
493 {
494 bool skipIt = false;
495 // combine it with next ?
496 if (i+1< (int)m_wdiffs.size())
497 {
498 if (m_wdiffs[i].end[0] + 1 == m_wdiffs[i+1].begin[0]
499 && m_wdiffs[i].end[1] + 1 == m_wdiffs[i+1].begin[1])
500 {
501 // diff[i] and diff[i+1] are contiguous
502 // so combine them into diff[i+1] and ignore diff[i]
503 m_wdiffs[i+1].begin[0] = m_wdiffs[i].begin[0];
504 m_wdiffs[i+1].begin[1] = m_wdiffs[i].begin[1];
505 skipIt = true;
506 }
507 }
508 if (!skipIt)
509 {
510 // Should never have a pair where both are missing
511 assert(m_wdiffs[i].begin[0]>=0 || m_wdiffs[i].begin[1]>=0);
512
513 // Store the diff[i] in the caller list (m_pDiffs)
514 m_pDiffs->emplace_back(m_wdiffs[i]);
515 }
516 }
517}
518
519// diffutils hash
520

Callers 1

ComputeWordDiffsFunction · 0.80

Calls 2

assertClass · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected