diff options
author | A-Team <ateam@pad.test.qt.nokia.com> | 2010-09-09 22:00:10 (GMT) |
---|---|---|
committer | A-Team <ateam@pad.test.qt.nokia.com> | 2010-09-09 22:00:10 (GMT) |
commit | 03c56248554b731356d283e467e1d31c54e78653 (patch) | |
tree | 5cfc5f5009f6534951f85257dddf1be1260b516f /src/corelib/tools | |
parent | dd387a0125b577fafc1a3363a4b8cd995053b7db (diff) | |
parent | 524379030503600bbca1a8e2b5889b91b0798203 (diff) | |
download | Qt-03c56248554b731356d283e467e1d31c54e78653.zip Qt-03c56248554b731356d283e467e1d31c54e78653.tar.gz Qt-03c56248554b731356d283e467e1d31c54e78653.tar.bz2 |
Merge branch '4.7-upstream' into 4.7-doc
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qbytearray.cpp | 41 | ||||
-rw-r--r-- | src/corelib/tools/qeasingcurve.cpp | 40 | ||||
-rw-r--r-- | src/corelib/tools/qsimd.cpp | 9 | ||||
-rw-r--r-- | src/corelib/tools/qvector.h | 4 |
4 files changed, 61 insertions, 33 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 8d38e4c..033da90 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -850,7 +850,7 @@ QByteArray::Data QByteArray::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1), This operation takes \l{constant time}, because QByteArray is \l{implicitly shared}. This makes returning a QByteArray from a function very fast. If a shared instance is modified, it will be - copied (copy-on-write), and that takes \l{linear time}. + copied (copy-on-write), taking \l{linear time}. \sa operator=() */ @@ -1186,10 +1186,18 @@ void QByteArray::chop(int n) Example: \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 12 - This operation is typically very fast (\l{constant time}), - because QByteArray preallocates extra space at the end of the - character data so it can grow without reallocating the entire - data each time. + Note: QByteArray is an \l{implicitly shared} class. Consequently, + if \e this is an empty QByteArray, then \e this will just share + the data held in \a ba. In this case, no copying of data is done, + taking \l{constant time}. If a shared instance is modified, it will + be copied (copy-on-write), taking \l{linear time}. + + If \e this is not an empty QByteArray, a deep copy of the data is + performed, taking \l{linear time}. + + This operation typically does not suffer from allocation overhead, + because QByteArray preallocates extra space at the end of the data + so that it may grow without reallocating for each append operation. \sa append(), prepend() */ @@ -1474,7 +1482,12 @@ QByteArray QByteArray::nulTerminated() const Note: QByteArray is an \l{implicitly shared} class. Consequently, if \e this is an empty QByteArray, then \e this will just share - the data held in \a ba. In this case, no copying of data is done. + the data held in \a ba. In this case, no copying of data is done, + taking \l{constant time}. If a shared instance is modified, it will + be copied (copy-on-write), taking \l{linear time}. + + If \e this is not an empty QByteArray, a deep copy of the data is + performed, taking \l{linear time}. \sa append(), insert() */ @@ -1547,14 +1560,18 @@ QByteArray &QByteArray::prepend(char ch) This is the same as insert(size(), \a ba). - This operation is typically very fast (\l{constant time}), - because QByteArray preallocates extra space at the end of the - character data so it can grow without reallocating the entire - data each time. - Note: QByteArray is an \l{implicitly shared} class. Consequently, if \e this is an empty QByteArray, then \e this will just share - the data held in \a ba. In this case, no copying of data is done. + the data held in \a ba. In this case, no copying of data is done, + taking \l{constant time}. If a shared instance is modified, it will + be copied (copy-on-write), taking \l{linear time}. + + If \e this is not an empty QByteArray, a deep copy of the data is + performed, taking \l{linear time}. + + This operation typically does not suffer from allocation overhead, + because QByteArray preallocates extra space at the end of the data + so that it may grow without reallocating for each append operation. \sa operator+=(), prepend(), insert() */ diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index ee791e0..7fe9170 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -332,7 +332,7 @@ public: enum Type { In, Out, InOut, OutIn }; QEasingCurveFunction(QEasingCurveFunction::Type type = In, qreal period = 0.3, qreal amplitude = 1.0, - qreal overshoot = 1.70158f) + qreal overshoot = 1.70158) : _t(type), _p(period), _a(amplitude), _o(overshoot) { } virtual ~QEasingCurveFunction() {} @@ -359,9 +359,9 @@ QEasingCurveFunction *QEasingCurveFunction::copy() const bool QEasingCurveFunction::operator==(const QEasingCurveFunction& other) { return _t == other._t && - _p == other._p && - _a == other._a && - _o == other._o; + qFuzzyCompare(_p, other._p) && + qFuzzyCompare(_a, other._a) && + qFuzzyCompare(_o, other._o); } QT_BEGIN_INCLUDE_NAMESPACE @@ -400,8 +400,8 @@ struct ElasticEase : public QEasingCurveFunction qreal value(qreal t) { - qreal p = (_p < 0) ? 0.3f : _p; - qreal a = (_a < 0) ? 1.0f : _a; + qreal p = (_p < 0) ? qreal(0.3) : _p; + qreal a = (_a < 0) ? qreal(1.0) : _a; switch(_t) { case In: return easeInElastic(t, a, p); @@ -420,7 +420,7 @@ struct ElasticEase : public QEasingCurveFunction struct BounceEase : public QEasingCurveFunction { BounceEase(Type type) - : QEasingCurveFunction(type, 0.3f, 1.0f) + : QEasingCurveFunction(type, qreal(0.3), qreal(1.0)) { } QEasingCurveFunction *copy() const @@ -432,7 +432,7 @@ struct BounceEase : public QEasingCurveFunction qreal value(qreal t) { - qreal a = (_a < 0) ? 1.0f : _a; + qreal a = (_a < 0) ? qreal(1.0) : _a; switch(_t) { case In: return easeInBounce(t, a); @@ -451,7 +451,7 @@ struct BounceEase : public QEasingCurveFunction struct BackEase : public QEasingCurveFunction { BackEase(Type type) - : QEasingCurveFunction(type, 0.3f, 1.0f, 1.70158f) + : QEasingCurveFunction(type, qreal(0.3), qreal(1.0), qreal(1.70158)) { } QEasingCurveFunction *copy() const @@ -463,7 +463,7 @@ struct BackEase : public QEasingCurveFunction qreal value(qreal t) { - qreal o = (_o < 0) ? 1.70158f : _o; + qreal o = (_o < 0) ? qreal(1.70158) : _o; switch(_t) { case In: return easeInBack(t, o); @@ -595,7 +595,7 @@ static QEasingCurveFunction *curveToFunctionObject(QEasingCurve::Type type) curveFunc = new BackEase(BackEase::OutIn); break; default: - curveFunc = new QEasingCurveFunction(QEasingCurveFunction::In, 0.3f, 1.0f, 1.70158f); // ### + curveFunc = new QEasingCurveFunction(QEasingCurveFunction::In, qreal(0.3), qreal(1.0), qreal(1.70158)); } return curveFunc; @@ -657,9 +657,17 @@ bool QEasingCurve::operator==(const QEasingCurve &other) const { bool res = d_ptr->func == other.d_ptr->func && d_ptr->type == other.d_ptr->type; - if (res && d_ptr->config && other.d_ptr->config) { + if (res) { + if (d_ptr->config && other.d_ptr->config) { // catch the config content - res = d_ptr->config->operator==(*(other.d_ptr->config)); + res = d_ptr->config->operator==(*(other.d_ptr->config)); + + } else if (d_ptr->config || other.d_ptr->config) { + // one one has a config object, which could contain default values + res = qFuzzyCompare(amplitude(), other.amplitude()) && + qFuzzyCompare(period(), other.period()) && + qFuzzyCompare(overshoot(), other.overshoot()); + } } return res; } @@ -681,7 +689,7 @@ bool QEasingCurve::operator==(const QEasingCurve &other) const */ qreal QEasingCurve::amplitude() const { - return d_ptr->config ? d_ptr->config->_a : 1.0; + return d_ptr->config ? d_ptr->config->_a : qreal(1.0); } /*! @@ -705,7 +713,7 @@ void QEasingCurve::setAmplitude(qreal amplitude) */ qreal QEasingCurve::period() const { - return d_ptr->config ? d_ptr->config->_p : 0.3; + return d_ptr->config ? d_ptr->config->_p : qreal(0.3); } /*! @@ -729,7 +737,7 @@ void QEasingCurve::setPeriod(qreal period) */ qreal QEasingCurve::overshoot() const { - return d_ptr->config ? d_ptr->config->_o : 1.70158f; + return d_ptr->config ? d_ptr->config->_o : qreal(1.70158) ; } /*! diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index a9c33f1..7babf3a 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -286,10 +286,13 @@ static inline uint detectProcessorFeatures() uint feature_result = 0; #if defined(Q_CC_GNU) - asm ("cpuid" - : "=c" (feature_result) + long tmp; + asm ("xchg %%rbx, %1\n" + "cpuid\n" + "xchg %%rbx, %1\n" + : "=c" (feature_result), "=&r" (tmp) : "a" (1) - : "%ebx", "%edx" + : "%edx" ); #elif defined (Q_OS_WIN64) { diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index b762b8a..2b8d054 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -293,9 +293,9 @@ public: #ifndef QT_NO_STL static inline QVector<T> fromStdVector(const std::vector<T> &vector) - { QVector<T> tmp; qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; } + { QVector<T> tmp; tmp.reserve(vector.size()); qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; } inline std::vector<T> toStdVector() const - { std::vector<T> tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; } + { std::vector<T> tmp; tmp.reserve(size()); qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; } #endif private: |