diff options
author | Bjoern Erik Nilsen <bnilsen@trolltech.com> | 2009-02-27 15:00:55 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2009-04-15 10:15:02 (GMT) |
commit | 50f92ce9b2cc8855a578423a1d309fba9b62dc5f (patch) | |
tree | 434ee82125c1da3cf0361d7d60a290310643d2a7 /src | |
parent | e87fd9a6fd06d57f4b007ab72c60041eaf0dec0f (diff) | |
download | Qt-50f92ce9b2cc8855a578423a1d309fba9b62dc5f.zip Qt-50f92ce9b2cc8855a578423a1d309fba9b62dc5f.tar.gz Qt-50f92ce9b2cc8855a578423a1d309fba9b62dc5f.tar.bz2 |
Fixes: Small optimization: reduce calls to QTransform::type().
Task: none
RevBy: Ariya Hidayat
AutoTest: Still pass.
Details: QTransform::type() is cached, so only the first call to it
should be expensive. However, it is not inlined so there's
an overhead involved (especially when these functions are
called a gazillion times).
(cherry picked from commit eda77b7c410a59d1b77c263994679452613d9d0b)
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/painting/qtransform.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 1a86e06..939a668 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -1222,7 +1222,8 @@ static QPolygonF mapProjective(const QTransform &transform, const QPolygonF &pol */ QPolygonF QTransform::map(const QPolygonF &a) const { - if (type() >= QTransform::TxProject) + TransformationType t = type(); + if (t >= QTransform::TxProject) return mapProjective(*this, a); int size = a.size(); @@ -1231,7 +1232,6 @@ QPolygonF QTransform::map(const QPolygonF &a) const const QPointF *da = a.constData(); QPointF *dp = p.data(); - TransformationType t = type(); for(i = 0; i < size; ++i) { MAP(da[i].xp, da[i].yp, dp[i].xp, dp[i].yp); } @@ -1249,7 +1249,8 @@ QPolygonF QTransform::map(const QPolygonF &a) const */ QPolygon QTransform::map(const QPolygon &a) const { - if (type() >= QTransform::TxProject) + TransformationType t = type(); + if (t >= QTransform::TxProject) return mapProjective(*this, QPolygonF(a)).toPolygon(); int size = a.size(); @@ -1258,7 +1259,6 @@ QPolygon QTransform::map(const QPolygon &a) const const QPoint *da = a.constData(); QPoint *dp = p.data(); - TransformationType t = type(); for(i = 0; i < size; ++i) { qreal nx = 0, ny = 0; MAP(da[i].xp, da[i].yp, nx, ny); @@ -2061,10 +2061,11 @@ QTransform::operator QVariant() const Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale) { - if (transform.type() <= QTransform::TxTranslate) { + const QTransform::TransformationType type = transform.type(); + if (type <= QTransform::TxTranslate) { *scale = 1; return true; - } else if (transform.type() == QTransform::TxScale) { + } else if (type == QTransform::TxScale) { const qreal xScale = qAbs(transform.m11()); const qreal yScale = qAbs(transform.m22()); *scale = qMax(xScale, yScale); @@ -2076,7 +2077,7 @@ bool qt_scaleForTransform(const QTransform &transform, qreal *scale) const qreal yScale = transform.m12() * transform.m12() + transform.m22() * transform.m22(); *scale = qSqrt(qMax(xScale, yScale)); - return transform.type() == QTransform::TxRotate && qFuzzyCompare(xScale, yScale); + return type == QTransform::TxRotate && qFuzzyCompare(xScale, yScale); } QT_END_NAMESPACE |