summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-01-17 09:42:47 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2011-01-17 15:07:17 (GMT)
commit0f9cbfc6124b331d006b396d56ad5ae0e6d548e0 (patch)
tree185a4d54640bdd5c42b35d6250a1a6ba5ca78344 /src
parent4c466703eb096b7ea0e18fb1efee0729ac688772 (diff)
downloadQt-0f9cbfc6124b331d006b396d56ad5ae0e6d548e0.zip
Qt-0f9cbfc6124b331d006b396d56ad5ae0e6d548e0.tar.gz
Qt-0f9cbfc6124b331d006b396d56ad5ae0e6d548e0.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
Diffstat (limited to 'src')
-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 945e45c..2a41b9e 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1123,14 +1123,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>