55// ---------------------------------------------------------------------
66// WsjcppDiffTextRow
77
8- WsjcppDiffTextRow::WsjcppDiffTextRow (int nNumberOfLine, std::string key, std::string line) {
8+ WsjcppDiffTextRow::WsjcppDiffTextRow (
9+ int nNumberOfLine,
10+ const std::string &sKey ,
11+ const std::string &sLine
12+ ) {
913 m_nNumberOfLine = nNumberOfLine;
10- this -> key = key ;
11- this -> line = line ;
14+ m_sKey = sKey ;
15+ m_sLine = sLine ;
1216}
1317
1418// ---------------------------------------------------------------------
@@ -17,6 +21,18 @@ int WsjcppDiffTextRow::getNumberOfLine() {
1721 return m_nNumberOfLine;
1822}
1923
24+ // ---------------------------------------------------------------------
25+
26+ std::string WsjcppDiffTextRow::getKey () {
27+ return m_sKey;
28+ }
29+
30+ // ---------------------------------------------------------------------
31+
32+ std::string WsjcppDiffTextRow::getLine () {
33+ return m_sLine;
34+ }
35+
2036// ---------------------------------------------------------------------
2137// WsjcppDiffText
2238
@@ -99,10 +115,10 @@ void WsjcppDiffText::merge(
99115 for (unsigned int i=0 ;i<arr2.size ();++i) {
100116 for (unsigned int j=0 ;j<arr1.size ();++j) {
101117 // delete of matches and 'del'/'add' overlays from the first vector
102- bool bLinesEqual = arr2.at (i)->line == arr1.at (j)->line ;
103- bool bKeysEqual = arr2.at (i)->key == arr1.at (j)->line ;
104- std::string sKey1 = arr1.at (j)->key ;
105- std::string sKey2 = arr2.at (i)->key ;
118+ bool bLinesEqual = arr2.at (i)->getLine () == arr1.at (j)->getLine () ;
119+ bool bKeysEqual = arr2.at (i)->getKey () == arr1.at (j)->getLine (); // TODO why comparing key and line ???
120+ std::string sKey1 = arr1.at (j)->getKey () ;
121+ std::string sKey2 = arr2.at (i)->getKey () ;
106122 if ((bLinesEqual && (sKey1 == sKey2 || sKey1 == " !add" ))
107123 || (bKeysEqual && (sKey1 == " !del" )))
108124 {
@@ -111,12 +127,12 @@ void WsjcppDiffText::merge(
111127 }
112128 }
113129 }
114- for (unsigned int i= 0 ;i< arr1.size ();++i) {
115- for (unsigned int j= 0 ;j< arr2.size ();++j) {
130+ for (unsigned int i = 0 ; i < arr1.size (); ++i) {
131+ for (unsigned int j = 0 ; j < arr2.size (); ++j) {
116132 // delete of del overlays from the second vector and update of priority
117- bool bLinesEqual = arr1.at (i)->key == arr2.at (j)->line ;
118- bool bKeysEqual = arr1.at (i)->key == arr2.at (j)->key ;
119- std::string sKey = arr2.at (j)->key ;
133+ bool bLinesEqual = arr1.at (i)->getKey () == arr2.at (j)->getLine (); // TODO check why comparing key and line here ?
134+ bool bKeysEqual = arr1.at (i)->getKey () == arr2.at (j)->getKey () ;
135+ std::string sKey = arr2.at (j)->getKey () ;
120136 if ((bLinesEqual && (sKey == " !del" ))
121137 || (bKeysEqual && (sKey != " !add" ) && (sKey != " !del" )))
122138 {
0 commit comments