Return an empty QStringList if the family string is empty

Since doing a split will create an empty entry, then we can save time
and just return an empty QStringList in this case

Change-Id: I86a6532e7243151493ea4021bfcc05e4c2a9cbf0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
bb10
Andy Shaw 2020-11-25 13:42:22 +01:00
parent c7a335817e
commit 420e27c9ef
2 changed files with 3 additions and 1 deletions

View File

@ -206,6 +206,8 @@ static int convertWeights(int weight, bool inverted)
static QStringList splitIntoFamilies(const QString &family)
{
QStringList familyList;
if (family.isEmpty())
return familyList;
const auto list = QStringView{family}.split(QLatin1Char(','));
const int numFamilies = list.size();
familyList.reserve(numFamilies);

View File

@ -850,7 +850,7 @@ QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *end
const QFont charFormatFont = charFormat.font();
AttributeFormatter attrs;
QString family = charFormatFont.families().first();
QString family = charFormatFont.families().value(0, QString());
if (!family.isEmpty()) {
family = family.replace(u'\\', QLatin1String("\\\\"));
family = family.replace(u':', QLatin1String("\\:"));