QTranslator: don't repeatedly re-create a QString from a QLatin1String
... each time around the loops. Cache it. Also use QStringLiteral, since the string will never be modified. Also saves 96b in text size on optimized GCC 4.9 Linux AMD64 builds. Change-Id: I0269586235da18f3073a553739561ea7db6356e8 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
c311815592
commit
5034d41630
@ -632,6 +632,7 @@ static QString find_translation(const QLocale & locale,
|
||||
if (!path.isEmpty() && !path.endsWith(QLatin1Char('/')))
|
||||
path += QLatin1Char('/');
|
||||
}
|
||||
const QString suffixOrDotQM = suffix.isNull() ? QStringLiteral(".qm") : suffix;
|
||||
|
||||
QString realname;
|
||||
realname += path + filename + prefix; // using += in the hope for some reserve capacity
|
||||
@ -654,7 +655,7 @@ static QString find_translation(const QLocale & locale,
|
||||
foreach (QString localeName, languages) {
|
||||
localeName.replace(QLatin1Char('-'), QLatin1Char('_'));
|
||||
|
||||
realname += localeName + (suffix.isNull() ? QLatin1String(".qm") : suffix);
|
||||
realname += localeName + suffixOrDotQM;
|
||||
if (is_readable_file(realname))
|
||||
return realname;
|
||||
|
||||
@ -675,7 +676,7 @@ static QString find_translation(const QLocale & locale,
|
||||
break;
|
||||
localeName.truncate(rightmost);
|
||||
|
||||
realname += localeName + (suffix.isNull() ? QLatin1String(".qm") : suffix);
|
||||
realname += localeName + suffixOrDotQM;
|
||||
if (is_readable_file(realname))
|
||||
return realname;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user