QFontDatabase: Optimize QtFontStyle::Key::Key().
Similar to 46b2c74eaf, skip the translations at
all costs. They allocate, and are very expensive. To ensure we try harder to
skip them, also avoid checking styles at all unless one has been provided.
This increases delegates_text from 209 items to 221 items for me.
Change-Id: Ia18b07de7b48cee356e9506a0c5d7129621d79d2
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
bb10
parent
071b286756
commit
5a23fcfa8a
|
|
@ -251,12 +251,19 @@ QtFontStyle::Key::Key(const QString &styleString)
|
|||
{
|
||||
weight = getFontWeight(styleString);
|
||||
|
||||
if (styleString.contains(QLatin1String("Italic"))
|
||||
|| styleString.contains(QCoreApplication::translate("QFontDatabase", "Italic")))
|
||||
style = QFont::StyleItalic;
|
||||
else if (styleString.contains(QLatin1String("Oblique"))
|
||||
|| styleString.contains(QCoreApplication::translate("QFontDatabase", "Oblique")))
|
||||
style = QFont::StyleOblique;
|
||||
if (!styleString.isEmpty()) {
|
||||
// First the straightforward no-translation checks, these are fast.
|
||||
if (styleString.contains(QLatin1String("Italic")))
|
||||
style = QFont::StyleItalic;
|
||||
else if (styleString.contains(QLatin1String("Oblique")))
|
||||
style = QFont::StyleOblique;
|
||||
|
||||
// Then the translation checks. These aren't as fast.
|
||||
else if (styleString.contains(QCoreApplication::translate("QFontDatabase", "Italic")))
|
||||
style = QFont::StyleItalic;
|
||||
else if (styleString.contains(QCoreApplication::translate("QFontDatabase", "Oblique")))
|
||||
style = QFont::StyleOblique;
|
||||
}
|
||||
}
|
||||
|
||||
QtFontSize *QtFontStyle::pixelSize(unsigned short size, bool add)
|
||||
|
|
|
|||
Loading…
Reference in New Issue