@@ -39,7 +39,7 @@ std::string WsjcppDiffTextRow::getLine() {
3939void WsjcppDiffText::compare (
4040 const std::string &sText1 ,
4141 const std::string &sText2 ,
42- std::vector<WsjcppDiffTextRow * > &vOutput
42+ std::vector<WsjcppDiffTextRow> &vOutput
4343) {
4444 std::vector<std::string> list1;
4545 std::istringstream isTxt1 (sText1 );
@@ -61,42 +61,42 @@ void WsjcppDiffText::compare(
6161
6262 int len1 = list1.size ();
6363 int len2 = list2.size ();
64- int i= 0 , j= 0 ;
64+ int i = 0 , j = 0 ;
6565 // main comparisons
6666 while ((i<len1) && (j<len2)) {
6767 if (list1[i] != list2[j]) {
68- // checkout for added rows
68+ // checkout for added rows
6969 for (int k = j + 1 ; k < len2; ++k) {
7070 if (list1[i] == list2[k]) {
7171 while (j<k) {
72- vOutput.push_back (new WsjcppDiffTextRow (j, sWord .at (0 ), list2.at (j)));
72+ vOutput.push_back (WsjcppDiffTextRow (j, sWord .at (0 ), list2.at (j)));
7373 j++;
7474 }
7575 goto exit;
7676 }
7777 }
78- // checkout for deleted rows
78+ // checkout for deleted rows
7979 for (int k=i+1 ;k<len1;++k) {
8080 if (list1[k]==list2[j]) {
8181 while (i<k) {
82- vOutput.push_back (new WsjcppDiffTextRow (i, sWord .at (1 ), list1.at (i)));
82+ vOutput.push_back (WsjcppDiffTextRow (i, sWord .at (1 ), list1.at (i)));
8383 i++;
8484 }
8585 goto exit;
8686 }
8787 }
88- vOutput.push_back (new WsjcppDiffTextRow (i, list1.at (i), list2.at (j)));
88+ vOutput.push_back (WsjcppDiffTextRow (i, list1.at (i), list2.at (j)));
8989 exit:;
9090 }
9191 i++, j++;
9292 }
9393 // work with the end of the texts
94- while (j< len2) {
95- vOutput.push_back (new WsjcppDiffTextRow (j, sWord .at (0 ), list2.at (j)));
94+ while (j < len2) {
95+ vOutput.push_back (WsjcppDiffTextRow (j, sWord .at (0 ), list2.at (j)));
9696 j++;
9797 }
98- while (i< len1) {
99- vOutput.push_back (new WsjcppDiffTextRow (i, sWord .at (1 ), list1.at (i)));
98+ while (i < len1) {
99+ vOutput.push_back (WsjcppDiffTextRow (i, sWord .at (1 ), list1.at (i)));
100100 i++;
101101 }
102102}
@@ -107,18 +107,18 @@ void WsjcppDiffText::merge(
107107 std::string &curtxt,
108108 std::string &txt1,
109109 std::string &txt2,
110- std::vector<WsjcppDiffTextRow * > &arr1,
111- std::vector<WsjcppDiffTextRow * > &arr2
110+ std::vector<WsjcppDiffTextRow> &arr1,
111+ std::vector<WsjcppDiffTextRow> &arr2
112112) {
113113 WsjcppDiffText::compare (txt1, txt2, arr1);
114114 WsjcppDiffText::compare (txt1, curtxt, arr2);
115115 for (unsigned int i=0 ;i<arr2.size ();++i) {
116116 for (unsigned int j=0 ;j<arr1.size ();++j) {
117117 // delete of matches and 'del'/'add' overlays from the first vector
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 ();
118+ bool bLinesEqual = arr2[i]. getLine () == arr1[j]. getLine ();
119+ bool bKeysEqual = arr2[i]. getKey () == arr1[j]. getLine (); // TODO why comparing key and line ???
120+ std::string sKey1 = arr1[j]. getKey ();
121+ std::string sKey2 = arr2[i]. getKey ();
122122 if ((bLinesEqual && (sKey1 == sKey2 || sKey1 == " !add" ))
123123 || (bKeysEqual && (sKey1 == " !del" )))
124124 {
@@ -130,9 +130,9 @@ void WsjcppDiffText::merge(
130130 for (unsigned int i = 0 ; i < arr1.size (); ++i) {
131131 for (unsigned int j = 0 ; j < arr2.size (); ++j) {
132132 // delete of del overlays from the second vector and update of priority
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 ();
133+ bool bLinesEqual = arr1[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 ();
136136 if ((bLinesEqual && (sKey == " !del" ))
137137 || (bKeysEqual && (sKey != " !add" ) && (sKey != " !del" )))
138138 {
@@ -146,7 +146,7 @@ void WsjcppDiffText::merge(
146146 arr1.insert (arr1.end (),arr2.begin (),arr2.end ());
147147 for (unsigned int i=0 ; i < arr1.size (); ++i) {
148148 for (unsigned int j = arr1.size ()-1 ; j > i; --j) {
149- if (arr1.at (j-1 )-> getNumberOfLine () > arr1.at (j)-> getNumberOfLine ()) {
149+ if (arr1.at (j-1 ). getNumberOfLine () > arr1.at (j). getNumberOfLine ()) {
150150 // TODO redesign
151151 std::swap (arr1.at (j-1 ), arr1.at (j));
152152 }
0 commit comments