Skip to content

Commit b546b6a

Browse files
committed
Keyframe: Dedicated Point comparision function instead of lambda's
1 parent 6f71736 commit b546b6a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/KeyFrame.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
using namespace std;
3636
using namespace openshot;
3737

38+
namespace {
39+
bool IsPointBeforeX(Point const & p, double const x) {
40+
return p.co.X < x;
41+
}
42+
}
43+
3844

3945
// Constructor which sets the default point & coordinate at X=1
4046
Keyframe::Keyframe(double value) {
@@ -48,9 +54,7 @@ void Keyframe::AddPoint(Point p) {
4854
// candidate is not less (greater or equal) than the new point in
4955
// the X coordinate.
5056
std::vector<Point>::iterator candidate =
51-
std::lower_bound(begin(Points), end(Points), p, [](Point const & l, Point const & r) {
52-
return l.co.X < r.co.X;
53-
});
57+
std::lower_bound(begin(Points), end(Points), p.co.X, IsPointBeforeX);
5458
if (candidate == end(Points)) {
5559
// New point X is greater than all other points' X, add to
5660
// back.
@@ -212,9 +216,7 @@ double Keyframe::GetValue(int64_t index) const {
212216
return 0;
213217
}
214218
std::vector<Point>::const_iterator candidate =
215-
std::lower_bound(begin(Points), end(Points), Point(index, -1), [](Point const & l, Point const & r) {
216-
return l.co.X < r.co.X;
217-
});
219+
std::lower_bound(begin(Points), end(Points), static_cast<double>(index), IsPointBeforeX);
218220

219221
if (candidate == end(Points)) {
220222
// index is behind last point

0 commit comments

Comments
 (0)