Use constFind()/constEnd() for const_iterator-s
authorKonstantin Ritt <ritt.ks@gmail.com>
Fri, 12 Oct 2012 04:08:18 +0000 (07:08 +0300)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sat, 13 Oct 2012 11:49:23 +0000 (13:49 +0200)
to make the strict iterators happy.

Change-Id: Ief4ec309b815f18dc4b2017d4f34c063db510c31
Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
src/gui/text/qfont.cpp
src/gui/text/qtextengine.cpp
src/gui/text/qtextformat.cpp

index a2132f0..24423ee 100644 (file)
@@ -2648,9 +2648,9 @@ void QFontCache::clear()
 
 QFontEngineData *QFontCache::findEngineData(const QFontDef &def) const
 {
-    EngineDataCache::ConstIterator it = engineDataCache.find(def),
-                                  end = engineDataCache.end();
-    if (it == end) return 0;
+    EngineDataCache::ConstIterator it = engineDataCache.constFind(def);
+    if (it == engineDataCache.constEnd())
+        return 0;
 
     // found
     return it.value();
index cff1487..33f2bba 100644 (file)
@@ -2741,13 +2741,13 @@ void QTextEngine::resolveAdditionalFormats() const
         const QScriptItem *si = &layoutData->items.at(i);
         int end = si->position + length(si);
 
-        while (startIt != addFormatSortedByStart.end() &&
+        while (startIt != addFormatSortedByStart.constEnd() &&
             specialData->addFormats.at(*startIt).start <= si->position) {
             currentFormats.insert(std::upper_bound(currentFormats.begin(), currentFormats.end(), *startIt),
                                   *startIt);
             ++startIt;
         }
-        while (endIt != addFormatSortedByEnd.end() &&
+        while (endIt != addFormatSortedByEnd.constEnd() &&
             specialData->addFormats.at(*endIt).start + specialData->addFormats.at(*endIt).length < end) {
             currentFormats.remove(qBinaryFind(currentFormats, *endIt) - currentFormats.begin());
             ++endIt;
index 6607c42..90cdd7e 100644 (file)
@@ -3358,8 +3358,8 @@ int QTextFormatCollection::indexForFormat(const QTextFormat &format)
 bool QTextFormatCollection::hasFormatCached(const QTextFormat &format) const
 {
     uint hash = getHash(format.d, format.format_type);
-    QMultiHash<uint, int>::const_iterator i = hashes.find(hash);
-    while (i != hashes.end() && i.key() == hash) {
+    QMultiHash<uint, int>::const_iterator i = hashes.constFind(hash);
+    while (i != hashes.constEnd() && i.key() == hash) {
         if (formats.value(i.value()) == format) {
             return true;
         }