summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-01-17 09:42:47 (GMT)
committerQt Commercial Integration <QtCommercial@digia.com>2012-01-31 10:24:56 (GMT)
commit51ded387ad9a2354eda145c10b71e6de2b01274d (patch)
tree93618e939461a1e23950e3aecbf674e33c99824f
parentaabc492f57c92509d9e321547fe1ee69e5925b20 (diff)
downloadQt-51ded387ad9a2354eda145c10b71e6de2b01274d.zip
Qt-51ded387ad9a2354eda145c10b71e6de2b01274d.tar.gz
Qt-51ded387ad9a2354eda145c10b71e6de2b01274d.tar.bz2
qRound: do not do operation with double when qreal is float
0.5 is double a literal, and they force computation on double while it would be more optimized on qreal if qreal is a float Task-number: QTBUG-16673 Reviewed-by: Thierry
-rw-r--r--src/corelib/global/qglobal.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 9fdcad1..46573ca 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1098,14 +1098,14 @@ template <typename T>
inline T qAbs(const T &t) { return t >= 0 ? t : -t; }
inline int qRound(qreal d)
-{ return d >= 0.0 ? int(d + 0.5) : int(d - int(d-1) + 0.5) + int(d-1); }
+{ return d >= qreal(0.0) ? int(d + qreal(0.5)) : int(d - int(d-1) + qreal(0.5)) + int(d-1); }
#if defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN)
inline qint64 qRound64(double d)
{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); }
#else
inline qint64 qRound64(qreal d)
-{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); }
+{ return d >= qreal(0.0) ? qint64(d + qreal(0.5)) : qint64(d - qreal(qint64(d-1)) + qreal(0.5)) + qint64(d-1); }
#endif
template <typename T>