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.
This commit is contained in:
Daniel Jour
2019-11-19 21:36:26 +01:00
parent d47c40dc14
commit 280504f007

View File

@@ -302,31 +302,12 @@ bool Keyframe::IsIncreasing(int index)
// Is index a valid point?
if (index >= 1 && (index + 1) < Values.size()) {
int64_t current_value = GetLong(index);
int64_t previous_value = 0;
int64_t next_value = 0;
int64_t previous_repeats = 0;
int64_t next_repeats = 0;
// Loop backwards and look for the next unique value
for (std::vector<Coordinate>::iterator backwards_it = Values.begin() + index; backwards_it != Values.begin(); backwards_it--) {
previous_value = long(round((*backwards_it).Y));
if (previous_value == current_value) {
// Found same value
previous_repeats++;
} else {
// Found non repeating value, no more repeats found
break;
}
}
// Loop forwards and look for the next unique value
for (std::vector<Coordinate>::iterator forwards_it = Values.begin() + (index + 1); forwards_it != Values.end(); forwards_it++) {
next_value = long(round((*forwards_it).Y));
if (next_value == current_value) {
// Found same value
next_repeats++;
} else {
// Found non repeating value, no more repeats found
if (next_value != current_value) {
break;
}
}