Skip to content

Commit 280504f

Browse files
committed
Keyframe::IsIncreasing() remove loop to previous values and counter
The previous values do not influence the return value of the function nor does looping over them have any side effect. The next_repeats value is not used in any way, thus it doesn't need to be calculated.
1 parent d47c40d commit 280504f

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

src/KeyFrame.cpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -302,31 +302,12 @@ bool Keyframe::IsIncreasing(int index)
302302
// Is index a valid point?
303303
if (index >= 1 && (index + 1) < Values.size()) {
304304
int64_t current_value = GetLong(index);
305-
int64_t previous_value = 0;
306305
int64_t next_value = 0;
307-
int64_t previous_repeats = 0;
308-
int64_t next_repeats = 0;
309-
310-
// Loop backwards and look for the next unique value
311-
for (std::vector<Coordinate>::iterator backwards_it = Values.begin() + index; backwards_it != Values.begin(); backwards_it--) {
312-
previous_value = long(round((*backwards_it).Y));
313-
if (previous_value == current_value) {
314-
// Found same value
315-
previous_repeats++;
316-
} else {
317-
// Found non repeating value, no more repeats found
318-
break;
319-
}
320-
}
321306

322307
// Loop forwards and look for the next unique value
323308
for (std::vector<Coordinate>::iterator forwards_it = Values.begin() + (index + 1); forwards_it != Values.end(); forwards_it++) {
324309
next_value = long(round((*forwards_it).Y));
325-
if (next_value == current_value) {
326-
// Found same value
327-
next_repeats++;
328-
} else {
329-
// Found non repeating value, no more repeats found
310+
if (next_value != current_value) {
330311
break;
331312
}
332313
}

0 commit comments

Comments
 (0)