summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2016-11-23 11:50:35 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-11-23 23:48:29 +0000
commit34be7dc9d09c45a5e47a13716ee4db70f95dabcf (patch)
tree74d3568810a103f8731fb60a61ef3e48411553e9 /src/gui/text
parentdc4c647137257fc7d3081db5d52f722c754e7dcb (diff)
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>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfontdatabase.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index d2da24ca94..5145385fdc 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -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()