Optimize fontdatabase fallbacksForFamily

Short-cut the case-insensitive string comparison when lengths doesn't
match.

This reduces the time spend in ucstricmp from 8% during start-up of the
textedit example, to under 1%.

Change-Id: Ib3a92900b330453289ec9eff4830dfac6a9a5da2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Allan Sandfeld Jensen 2016-11-23 11:50:35 +01:00
parent dc4c647137
commit 34be7dc9d0
1 changed files with 6 additions and 1 deletions

View File

@ -406,9 +406,14 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create)
return foundries[count++];
}
static inline bool equalsCaseInsensitive(const QString &a, const QString &b)
{
return a.size() == b.size() && a.compare(b, Qt::CaseInsensitive) == 0;
}
bool QtFontFamily::matchesFamilyName(const QString &familyName) const
{
return name.compare(familyName, Qt::CaseInsensitive) == 0 || aliases.contains(familyName, Qt::CaseInsensitive);
return equalsCaseInsensitive(name, familyName) || aliases.contains(familyName, Qt::CaseInsensitive);
}
void QtFontFamily::ensurePopulated()