QFontDatabase: Optimize QtFontStyle::Key::Key().
Similar to 46b2c74eaf95fc607518988c7958574c7f70f5ae, 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>
This commit is contained in:
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…
x
Reference in New Issue
Block a user