Thread: [Winmerge-svn] SF.net SVN: winmerge:[6278] trunk/Src/MergeDocLineDiffs.cpp
Windows visual diff and merge for files and directories
Brought to you by:
christianlist,
grimmdp
From: <ki...@us...> - 2009-01-03 10:27:50
|
Revision: 6278 http://winmerge.svn.sourceforge.net/winmerge/?rev=6278&view=rev Author: kimmov Date: 2009-01-03 10:27:44 +0000 (Sat, 03 Jan 2009) Log Message: ----------- PATCH: [ 2481057 ] MergeDocLineDiffs.cpp Submitted by Matthias Mayer Modified Paths: -------------- trunk/Src/MergeDocLineDiffs.cpp Modified: trunk/Src/MergeDocLineDiffs.cpp =================================================================== --- trunk/Src/MergeDocLineDiffs.cpp 2009-01-03 10:11:12 UTC (rev 6277) +++ trunk/Src/MergeDocLineDiffs.cpp 2009-01-03 10:27:44 UTC (rev 6278) @@ -264,7 +264,7 @@ { // Find starting locations for both sides // Have to look for first valid starting location for each side - vector<wdiff*>::size_type i; + vector<wdiff*>::size_type i; for (i=0; i<worddiffs.size(); ++i) { const wdiff * diff = worddiffs[i]; @@ -277,15 +277,18 @@ } // Find ending locations for both sides // Have to look for last valid starting location for each side - for (i=worddiffs.size() - 1; i>=0; --i) + if (worddiffs.size() > 1) { - const wdiff * diff = worddiffs[i]; - if (end1 == -1 && diff->end[0] != -1) - end1 = diff->end[0]; - if (end2 == -1 && diff->end[1] != -1) - end2 = diff->end[1]; - if (end1 != -1 && end2 != -1) - break; // found both + for (i = worddiffs.size() - 1; i >= 0; --i) + { + const wdiff * diff = worddiffs[i]; + if (end1 == -1 && diff->end[0] != -1) + end1 = diff->end[0]; + if (end2 == -1 && diff->end[1] != -1) + end2 = diff->end[1]; + if (end1 != -1 && end2 != -1) + break; // found both + } } SetLineHighlightRect(begin1, end1, line, width1, rc1); SetLineHighlightRect(begin2, end2, line, width2, rc2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ki...@us...> - 2009-01-24 11:18:57
|
Revision: 6374 http://winmerge.svn.sourceforge.net/winmerge/?rev=6374&view=rev Author: kimmov Date: 2009-01-24 11:18:52 +0000 (Sat, 24 Jan 2009) Log Message: ----------- Optimization: use iterator instead of index operator when looping through vector. Modified Paths: -------------- trunk/Src/MergeDocLineDiffs.cpp Modified: trunk/Src/MergeDocLineDiffs.cpp =================================================================== --- trunk/Src/MergeDocLineDiffs.cpp 2009-01-24 00:54:46 UTC (rev 6373) +++ trunk/Src/MergeDocLineDiffs.cpp 2009-01-24 11:18:52 UTC (rev 6374) @@ -264,31 +264,33 @@ { // Find starting locations for both sides // Have to look for first valid starting location for each side - vector<wdiff*>::size_type i; - for (i=0; i<worddiffs.size(); ++i) + vector<wdiff*>::const_iterator it = worddiffs.begin(); + while (it != worddiffs.end()) { - const wdiff * diff = worddiffs[i]; - if (begin1 == -1 && diff->start[0] != -1) - begin1 = diff->start[0]; - if (begin2 == -1 && diff->start[1] != -1) - begin2 = diff->start[1]; + //const wdiff * diff = *it; + if (begin1 == -1 && (*it)->start[0] != -1) + begin1 = (*it)->start[0]; + if (begin2 == -1 && (*it)->start[1] != -1) + begin2 = (*it)->start[1]; if (begin1 != -1 && begin2 != -1) break; // found both + it++; } // Find ending locations for both sides // Have to look for last valid starting location for each side if (worddiffs.size() > 1) { - for (i = worddiffs.size() - 1; i >= 0; --i) + vector<wdiff*>::const_iterator it = worddiffs.end(); + do { - const wdiff * diff = worddiffs[i]; - if (end1 == -1 && diff->end[0] != -1) - end1 = diff->end[0]; - if (end2 == -1 && diff->end[1] != -1) - end2 = diff->end[1]; + it--; + if (end1 == -1 && (*it)->end[0] != -1) + end1 = (*it)->end[0]; + if (end2 == -1 && (*it)->end[1] != -1) + end2 = (*it)->end[1]; if (end1 != -1 && end2 != -1) break; // found both - } + } while (it != worddiffs.begin()); } SetLineHighlightRect(begin1, end1, line, width1, rc1); SetLineHighlightRect(begin2, end2, line, width2, rc2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ki...@us...> - 2009-12-29 14:22:56
|
Revision: 7067 http://winmerge.svn.sourceforge.net/winmerge/?rev=7067&view=rev Author: kimmov Date: 2009-12-29 14:22:46 +0000 (Tue, 29 Dec 2009) Log Message: ----------- PATCH: [ 2922223 ] MergeDocLineDiffs clean up Submitted by Matthias Mayer Modified Paths: -------------- trunk/Src/MergeDocLineDiffs.cpp Modified: trunk/Src/MergeDocLineDiffs.cpp =================================================================== --- trunk/Src/MergeDocLineDiffs.cpp 2009-12-28 20:28:18 UTC (rev 7066) +++ trunk/Src/MergeDocLineDiffs.cpp 2009-12-29 14:22:46 UTC (rev 7067) @@ -193,31 +193,14 @@ DIFFOPTIONS diffOptions = {0}; m_diffWrapper.GetOptions(&diffOptions); + i1 = m_pView[0]->GetLineLength(line); + i2 = m_pView[1]->GetLineLength(line); + String str1(m_pView[0]->GetLineChars(line), i1); + String str2(m_pView[1]->GetLineChars(line), i2); - String str1(pView1->GetLineChars(line), pView1->GetFullLineLength(line)); - String str2(pView2->GetLineChars(line), pView2->GetFullLineLength(line)); - - /* Commented out code because GetLineActualLength is buggy - // Chop of eol (end of line) characters - int len1 = pView1->GetLineActualLength(line); - str1 = str1.Left(len1); - int len2 = pView2->GetLineActualLength(line); - str2 = str2.Left(len2); - */ - i1 = str1.length() - 1; - while (i1 >= 0 && (str1[i1] == '\r' || str1[i1] == '\n')) - --i1; - if (i1 + 1 < str1.length()) - str1.resize(i1 + 1); - i2 = str2.length() - 1; - while (i2 >= 0 && (str2[i2]=='\r' || str2[i2]=='\n')) - --i2; - if (i2+1 < str2.length()) - str2.resize(i2 + 1); - // We truncate diffs to remain inside line (ie, to not flag eol characters) - int width1 = pView1->GetLineLength(line); - int width2 = pView2->GetLineLength(line); + int width1 = i1; + int width2 = i2; // Options that affect comparison bool casitive = !diffOptions.bIgnoreCase; @@ -232,7 +215,7 @@ { if (pView1->GetTextBufferEol(line) != pView1->GetTextBufferEol(line)) { - wdiff *wdf = new wdiff(++i1, i1, ++i2, i2); + wdiff *wdf = new wdiff(i1, i1, i2, i2); worddiffs.push_back(wdf); } } @@ -335,28 +318,11 @@ DIFFOPTIONS diffOptions = {0}; m_diffWrapper.GetOptions(&diffOptions); + i1 = m_pView[0]->GetLineLength(nLineIndex); + i2 = m_pView[1]->GetLineLength(nLineIndex); + String str1(m_pView[0]->GetLineChars(nLineIndex), i1); + String str2(m_pView[1]->GetLineChars(nLineIndex), i2); - String str1(m_pView[0]->GetLineChars(nLineIndex), m_pView[0]->GetFullLineLength(nLineIndex)); - String str2(m_pView[1]->GetLineChars(nLineIndex), m_pView[1]->GetFullLineLength(nLineIndex)); - - /* Commented out code because GetLineActualLength is buggy - // Chop of eol (end of line) characters - int len1 = pView1->GetLineActualLength(line); - str1 = str1.Left(len1); - int len2 = pView2->GetLineActualLength(line); - str2 = str2.Left(len2); - */ - i1 = str1.length() - 1; - while (i1 >= 0 && (str1[i1] == '\r' || str1[i1] == '\n')) - --i1; - if (i1 + 1 < str1.length()) - str1.resize(i1 + 1); - i2 = str2.length() - 1; - while (i2 >= 0 && (str2[i2]=='\r' || str2[i2]=='\n')) - --i2; - if (i2+1 < str2.length()) - str2.resize(i2 + 1); - // Options that affect comparison bool casitive = !diffOptions.bIgnoreCase; int xwhite = diffOptions.nIgnoreWhitespace; @@ -370,7 +336,7 @@ { if (m_pView[0]->GetTextBufferEol(nLineIndex) != m_pView[1]->GetTextBufferEol(nLineIndex)) { - wdiff *wdf = new wdiff(++i1, i1, ++i2, i2); + wdiff *wdf = new wdiff(i1, i1, i2, i2); pworddiffs->push_back(wdf); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |