diff options
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qcryptographichash.cpp | 4 | ||||
-rw-r--r-- | src/corelib/tools/qeasingcurve.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qhash.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qhash.h | 28 | ||||
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 13 | ||||
-rw-r--r-- | src/corelib/tools/qmap.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qset.qdoc | 2 | ||||
-rw-r--r-- | src/corelib/tools/qstringbuilder.cpp | 4 | ||||
-rw-r--r-- | src/corelib/tools/qtimeline.cpp | 2 |
9 files changed, 43 insertions, 16 deletions
diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 963a91b9a9..5410adc737 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -494,3 +494,7 @@ QByteArray QCryptographicHash::hash(const QByteArray &data, Algorithm method) } QT_END_NAMESPACE + +#ifndef QT_NO_QOBJECT +#include "moc_qcryptographichash.cpp" +#endif diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 4b5f5e7830..03bb1a1411 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -1501,3 +1501,5 @@ QDataStream &operator>>(QDataStream &stream, QEasingCurve &easing) #endif // QT_NO_DATASTREAM QT_END_NAMESPACE + +#include "moc_qeasingcurve.cpp" diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 353dc834aa..59aab32347 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -2609,7 +2609,7 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW /*! \fn QMultiHash::QMultiHash(std::initializer_list<std::pair<Key,T> > list) \since 5.1 - Constructs a multi hash with a copy of each of the elements in the + Constructs a multi-hash with a copy of each of the elements in the initializer list \a list. This function is only available if the program is being diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index bcaaec0ec6..8689243a98 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -51,6 +51,8 @@ #include <initializer_list> #endif +#include <algorithm> + #if defined(Q_CC_MSVC) #pragma warning( push ) #pragma warning( disable : 4311 ) // disable pointer truncation warning @@ -945,18 +947,24 @@ Q_OUTOFLINE_TEMPLATE bool QHash<Key, T>::operator==(const QHash &other) const const_iterator it = begin(); while (it != end()) { - const Key &akey = it.key(); + // Build two equal ranges for i.key(); one for *this and one for other. + // For *this we can avoid a lookup via equal_range, as we know the beginning of the range. + auto thisEqualRangeEnd = it; + while (thisEqualRangeEnd != end() && it.key() == thisEqualRangeEnd.key()) + ++thisEqualRangeEnd; - const_iterator it2 = other.find(akey); - do { - if (it2 == other.end() || !(it2.key() == akey)) - return false; - if (!(it.value() == it2.value())) - return false; - ++it; - ++it2; - } while (it != end() && it.key() == akey); + const auto otherEqualRange = other.equal_range(it.key()); + + if (std::distance(it, thisEqualRangeEnd) != std::distance(otherEqualRange.first, otherEqualRange.second)) + return false; + + // Keys in the ranges are equal by construction; this checks only the values. + if (!std::is_permutation(it, thisEqualRangeEnd, otherEqualRange.first)) + return false; + + it = thisEqualRangeEnd; } + return true; } diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 0a573e77dc..5557b5af2d 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -3226,14 +3226,18 @@ QString QLocaleData::unsLongLongToString(const QChar zero, const QChar group, int base, int width, unsigned flags) { + const QChar resultZero = base == 10 ? zero : QChar(QLatin1Char('0')); + QString num_str = l ? qulltoa(l, base, zero) : QString(resultZero); + bool precision_not_specified = false; if (precision == -1) { + if (flags == NoFlags) + return num_str; // fast-path: nothing below applies, so we're done. + precision_not_specified = true; precision = 1; } - QString num_str = qulltoa(l, base, zero); - uint cnt_thousand_sep = 0; if (flags & ThousandsGroup && base == 10) { for (int i = num_str.length() - 3; i > 0; i -=3) { @@ -3242,7 +3246,6 @@ QString QLocaleData::unsLongLongToString(const QChar zero, const QChar group, } } - const QChar resultZero = base == 10 ? zero : QChar(QLatin1Char('0')); const int zeroPadding = precision - num_str.length()/* + cnt_thousand_sep*/; if (zeroPadding > 0) num_str.prepend(QString(zeroPadding, resultZero)); @@ -3873,3 +3876,7 @@ QDebug operator<<(QDebug dbg, const QLocale &l) } #endif QT_END_NAMESPACE + +#ifndef QT_NO_QOBJECT +#include "moc_qlocale.cpp" +#endif diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index 9738e2ed18..afdd30e5c8 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -1934,7 +1934,7 @@ void QMapDataBase::freeData(QMapDataBase *d) /*! \fn QMultiMap::QMultiMap(std::initializer_list<std::pair<Key,T> > list) \since 5.1 - Constructs a multi map with a copy of each of the elements in the + Constructs a multi-map with a copy of each of the elements in the initializer list \a list. This function is only available if the program is being diff --git a/src/corelib/tools/qset.qdoc b/src/corelib/tools/qset.qdoc index 48dcc9eec0..93f157fdc5 100644 --- a/src/corelib/tools/qset.qdoc +++ b/src/corelib/tools/qset.qdoc @@ -530,7 +530,7 @@ */ /*! - \fn QSet::const_iterator QSet::insert(const T &value) + \fn QSet::insert(const T &value) Inserts item \a value into the set, if \a value isn't already in the set, and returns an iterator pointing at the inserted diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index 70152a9202..56ba909e2f 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -72,17 +72,21 @@ QT_BEGIN_NAMESPACE For building QStrings: + \list \li QString, QStringRef, \li QChar, QCharRef, QLatin1Char, \li QLatin1String, \li QByteArray, \c char, \c{const char[]}. + \endlist The types in the last list point are only available when QT_NO_CAST_FROM_ASCII is not defined. For building QByteArrays: + \list \li QByteArray, \c char, \c{const char[]}. + \endlist Concatenating strings with operator%() generally yields better performance than using \c QString::operator+() on the same chunks diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp index adbc2900e3..e70e7f8e16 100644 --- a/src/corelib/tools/qtimeline.cpp +++ b/src/corelib/tools/qtimeline.cpp @@ -784,3 +784,5 @@ void QTimeLine::timerEvent(QTimerEvent *event) } QT_END_NAMESPACE + +#include "moc_qtimeline.cpp" |