From c3b261f3f0df0795053ecf23b401d06c0cb6d075 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 10 Dec 2015 14:28:13 +0400 Subject: Deduplicate and clarify the code a bit Makes it clear that the engine for font with no Latin WS support won't be cached as "shared" engine and thus shouldn't be normally expected in the cache, so don't even try to find it there. Change-Id: I9e6275b4919607f4057a193b446825c98932bd23 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontdatabase.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index f20f574bc6..15882679cc 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -924,7 +924,10 @@ QFontEngine *loadSingleEngine(int script, QFontCache::Key key(def,script); QFontEngine *engine = QFontCache::instance()->findEngine(key); if (!engine) { - if (script != QChar::Script_Common) { + const bool cacheForCommonScript = script != QChar::Script_Common + && (family->writingSystems[QFontDatabase::Latin] & QtFontFamily::Supported) != 0; + + if (Q_LIKELY(cacheForCommonScript)) { // fast path: check if engine was loaded for another script key.script = QChar::Script_Common; engine = QFontCache::instance()->findEngine(key); @@ -963,7 +966,7 @@ QFontEngine *loadSingleEngine(int script, QFontCache::instance()->insertEngine(key, engine); - if (!engine->symbol && script != QChar::Script_Common && (family->writingSystems[QFontDatabase::Latin] & QtFontFamily::Supported) != 0) { + if (Q_LIKELY(cacheForCommonScript && !engine->symbol)) { // cache engine for Common script as well key.script = QChar::Script_Common; if (!QFontCache::instance()->findEngine(key)) -- cgit v1.2.3