forked from qt-creator/qt-creator
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:
@@ -65,15 +65,14 @@ int EasingCurve::segmentCount() const
|
||||
bool EasingCurve::isLegal() const
|
||||
{
|
||||
QPainterPath painterPath(path());
|
||||
|
||||
double increment = 1.0 / 30.0;
|
||||
QPointF max = painterPath.pointAtPercent(0.0);
|
||||
for (double i = increment; i <= 1.0; i += increment) {
|
||||
QPointF current = painterPath.pointAtPercent(i);
|
||||
if (current.x() < max.x())
|
||||
qreal maxX = painterPath.pointAtPercent(0.0).x();
|
||||
const int denominator = 30;
|
||||
for (int i = 1; i <= denominator; ++i) {
|
||||
const qreal currentX = painterPath.pointAtPercent(qreal(i) / denominator).x();
|
||||
if (currentX < maxX)
|
||||
return false;
|
||||
else
|
||||
max = current;
|
||||
maxX = currentX;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user