EasingCurve: Avoid iterating double

Iterate int instead. Store the x() value of QPointF,
instead of storing the whold QPointF instance.

Change-Id: I8c19eaa81cd60c4a164392afd5429ad9a2d222bd
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Jarek Kobus
2023-08-04 12:26:02 +02:00
parent 4b4cbd142c
commit fe1aeb3057

View File

@@ -65,15 +65,14 @@ int EasingCurve::segmentCount() const
bool EasingCurve::isLegal() const bool EasingCurve::isLegal() const
{ {
QPainterPath painterPath(path()); QPainterPath painterPath(path());
qreal maxX = painterPath.pointAtPercent(0.0).x();
double increment = 1.0 / 30.0; const int denominator = 30;
QPointF max = painterPath.pointAtPercent(0.0); for (int i = 1; i <= denominator; ++i) {
for (double i = increment; i <= 1.0; i += increment) { const qreal currentX = painterPath.pointAtPercent(qreal(i) / denominator).x();
QPointF current = painterPath.pointAtPercent(i); if (currentX < maxX)
if (current.x() < max.x())
return false; return false;
else else
max = current; maxX = currentX;
} }
return true; return true;
} }