@@ -39,7 +39,7 @@ std::string WsjcppDiffTextRow::getLine() {
39
39
void WsjcppDiffText::compare (
40
40
const std::string &sText1 ,
41
41
const std::string &sText2 ,
42
- std::vector<WsjcppDiffTextRow * > &vOutput
42
+ std::vector<WsjcppDiffTextRow> &vOutput
43
43
) {
44
44
std::vector<std::string> list1;
45
45
std::istringstream isTxt1 (sText1 );
@@ -61,42 +61,42 @@ void WsjcppDiffText::compare(
61
61
62
62
int len1 = list1.size ();
63
63
int len2 = list2.size ();
64
- int i= 0 , j= 0 ;
64
+ int i = 0 , j = 0 ;
65
65
// main comparisons
66
66
while ((i<len1) && (j<len2)) {
67
67
if (list1[i] != list2[j]) {
68
- // checkout for added rows
68
+ // checkout for added rows
69
69
for (int k = j + 1 ; k < len2; ++k) {
70
70
if (list1[i] == list2[k]) {
71
71
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)));
73
73
j++;
74
74
}
75
75
goto exit;
76
76
}
77
77
}
78
- // checkout for deleted rows
78
+ // checkout for deleted rows
79
79
for (int k=i+1 ;k<len1;++k) {
80
80
if (list1[k]==list2[j]) {
81
81
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)));
83
83
i++;
84
84
}
85
85
goto exit;
86
86
}
87
87
}
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)));
89
89
exit:;
90
90
}
91
91
i++, j++;
92
92
}
93
93
// 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)));
96
96
j++;
97
97
}
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)));
100
100
i++;
101
101
}
102
102
}
@@ -107,18 +107,18 @@ void WsjcppDiffText::merge(
107
107
std::string &curtxt,
108
108
std::string &txt1,
109
109
std::string &txt2,
110
- std::vector<WsjcppDiffTextRow * > &arr1,
111
- std::vector<WsjcppDiffTextRow * > &arr2
110
+ std::vector<WsjcppDiffTextRow> &arr1,
111
+ std::vector<WsjcppDiffTextRow> &arr2
112
112
) {
113
113
WsjcppDiffText::compare (txt1, txt2, arr1);
114
114
WsjcppDiffText::compare (txt1, curtxt, arr2);
115
115
for (unsigned int i=0 ;i<arr2.size ();++i) {
116
116
for (unsigned int j=0 ;j<arr1.size ();++j) {
117
117
// 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 ();
122
122
if ((bLinesEqual && (sKey1 == sKey2 || sKey1 == " !add" ))
123
123
|| (bKeysEqual && (sKey1 == " !del" )))
124
124
{
@@ -130,9 +130,9 @@ void WsjcppDiffText::merge(
130
130
for (unsigned int i = 0 ; i < arr1.size (); ++i) {
131
131
for (unsigned int j = 0 ; j < arr2.size (); ++j) {
132
132
// 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 ();
136
136
if ((bLinesEqual && (sKey == " !del" ))
137
137
|| (bKeysEqual && (sKey != " !add" ) && (sKey != " !del" )))
138
138
{
@@ -146,7 +146,7 @@ void WsjcppDiffText::merge(
146
146
arr1.insert (arr1.end (),arr2.begin (),arr2.end ());
147
147
for (unsigned int i=0 ; i < arr1.size (); ++i) {
148
148
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 ()) {
150
150
// TODO redesign
151
151
std::swap (arr1.at (j-1 ), arr1.at (j));
152
152
}
0 commit comments