From ce86d7385090746c3baf2991dd1cacb911ff6d88 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 13 Feb 2015 22:06:48 +0100 Subject: QFontDatabase: Move style key near usage to avoid heap allocs Raises delegates_text.qml to 233 ops/frame Change-Id: I88a26d2a9e4dc12ebbbc07329141976c194555ec Reviewed-by: Konstantin Ritt --- src/gui/text/qfontdatabase.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 127a2efa8c..211b8b6659 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -1570,11 +1570,10 @@ bool QFontDatabase::isBitmapScalable(const QString &family, QT_PREPEND_NAMESPACE(load)(familyName); - QtFontStyle::Key styleKey(style); - QtFontFamily *f = d->family(familyName); if (!f) return bitmapScalable; + QtFontStyle::Key styleKey(style); for (int j = 0; j < f->count; j++) { QtFontFoundry *foundry = f->foundries[j]; if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) { @@ -1614,8 +1613,6 @@ bool QFontDatabase::isSmoothlyScalable(const QString &family, const QString &sty QT_PREPEND_NAMESPACE(load)(familyName); - QtFontStyle::Key styleKey(style); - QtFontFamily *f = d->family(familyName); if (!f) { for (int i = 0; i < d->count; i++) { @@ -1628,6 +1625,7 @@ bool QFontDatabase::isSmoothlyScalable(const QString &family, const QString &sty } if (!f) return smoothScalable; + QtFontStyle::Key styleKey(style); for (int j = 0; j < f->count; j++) { QtFontFoundry *foundry = f->foundries[j]; if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) { @@ -1680,8 +1678,6 @@ QList QFontDatabase::pointSizes(const QString &family, QT_PREPEND_NAMESPACE(load)(familyName); - QtFontStyle::Key styleKey(styleName); - QList sizes; QtFontFamily *fam = d->family(familyName); @@ -1690,6 +1686,7 @@ QList QFontDatabase::pointSizes(const QString &family, const int dpi = qt_defaultDpiY(); // embedded + QtFontStyle::Key styleKey(styleName); for (int j = 0; j < fam->count; j++) { QtFontFoundry *foundry = fam->foundries[j]; if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) { @@ -1783,8 +1780,6 @@ QList QFontDatabase::smoothSizes(const QString &family, QT_PREPEND_NAMESPACE(load)(familyName); - QtFontStyle::Key styleKey(styleName); - QList sizes; QtFontFamily *fam = d->family(familyName); @@ -1793,6 +1788,7 @@ QList QFontDatabase::smoothSizes(const QString &family, const int dpi = qt_defaultDpiY(); // embedded + QtFontStyle::Key styleKey(styleName); for (int j = 0; j < fam->count; j++) { QtFontFoundry *foundry = fam->foundries[j]; if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) { -- cgit v1.2.3