From b70327923527bd9f10e258ca8fd170d5916b9ae6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 30 Apr 2019 15:11:29 +0200 Subject: [PATCH] QFontEngine: replace QLinkedList with std::list The object is never copied, so there's no point in using a cow'ed list implementation. Also port two explicit-iterator loops to ranged-for, as one is necessary (because of constBegin()) and the other is for consistency. Change-Id: Ia7f080060d6b675a76b55d197af08161389082a9 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- src/gui/text/qfontengine.cpp | 10 +++++----- src/gui/text/qfontengine_p.h | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 99c9e1bfdc..537d4bcefd 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1059,15 +1059,15 @@ void QFontEngine::setGlyphCache(const void *context, QFontEngineGlyphCache *cach Q_ASSERT(cache); GlyphCaches &caches = m_glyphCaches[context]; - for (GlyphCaches::const_iterator it = caches.constBegin(), end = caches.constEnd(); it != end; ++it) { - if (cache == it->cache.data()) + for (auto & e : caches) { + if (cache == e.cache.data()) return; } // Limit the glyph caches to 4 per context. This covers all 90 degree rotations, // and limits memory use when there is continuous or random rotation if (caches.size() == 4) - caches.removeLast(); + caches.pop_back(); GlyphCacheEntry entry; entry.cache = cache; @@ -1081,8 +1081,8 @@ QFontEngineGlyphCache *QFontEngine::glyphCache(const void *context, GlyphFormat if (caches == m_glyphCaches.cend()) return nullptr; - for (GlyphCaches::const_iterator it = caches->begin(), end = caches->end(); it != end; ++it) { - QFontEngineGlyphCache *cache = it->cache.data(); + for (auto &e : *caches) { + QFontEngineGlyphCache *cache = e.cache.data(); if (format == cache->glyphFormat() && qtransform_equals_no_translate(cache->m_transform, transform)) return cache; } diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index b922d50b4c..8dcfd7d66c 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -54,7 +54,6 @@ #include #include "QtCore/qatomic.h" #include -#include #include #include "private/qtextengine_p.h" #include "private/qfont_p.h" @@ -370,7 +369,7 @@ private: QExplicitlySharedDataPointer cache; bool operator==(const GlyphCacheEntry &other) const { return cache == other.cache; } }; - typedef QLinkedList GlyphCaches; + typedef std::list GlyphCaches; mutable QHash m_glyphCaches; private: