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 <eskil.abrahamsen-blomfeldt@theqtcompany.com>
bb10
Konstantin Ritt 2015-12-10 14:28:13 +04:00
parent f5e02d4128
commit c3b261f3f0
1 changed files with 5 additions and 2 deletions

View File

@ -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))