QLocalePrivate: overload codeToCountry() for QStringRef and QChar array
Now we can use QStringRef arg or QChar array arg to avoid unnecessary allocations. Also mark these functions as Q_DECL_NOTHROW. Change-Id: I22b08a054051e80e3f76bb543d860f3dcb6caa4f Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
parent
342290888f
commit
80d1e732d8
@ -154,9 +154,8 @@ QLocale::Script QLocalePrivate::codeToScript(const QString &code)
|
|||||||
return QLocale::AnyScript;
|
return QLocale::AnyScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
QLocale::Country QLocalePrivate::codeToCountry(const QString &code)
|
QLocale::Country QLocalePrivate::codeToCountry(const QChar *code, int len) Q_DECL_NOTHROW
|
||||||
{
|
{
|
||||||
int len = code.length();
|
|
||||||
if (len != 2 && len != 3)
|
if (len != 2 && len != 3)
|
||||||
return QLocale::AnyCountry;
|
return QLocale::AnyCountry;
|
||||||
ushort uc1 = code[0].toUpper().unicode();
|
ushort uc1 = code[0].toUpper().unicode();
|
||||||
|
@ -355,7 +355,9 @@ public:
|
|||||||
static QString countryToCode(QLocale::Country country);
|
static QString countryToCode(QLocale::Country country);
|
||||||
static QLocale::Language codeToLanguage(const QString &code);
|
static QLocale::Language codeToLanguage(const QString &code);
|
||||||
static QLocale::Script codeToScript(const QString &code);
|
static QLocale::Script codeToScript(const QString &code);
|
||||||
static QLocale::Country codeToCountry(const QString &code);
|
static QLocale::Country codeToCountry(const QChar *code, int len) Q_DECL_NOTHROW;
|
||||||
|
static QLocale::Country codeToCountry(const QString &code) Q_DECL_NOTHROW { return codeToCountry(code.data(), code.size()); }
|
||||||
|
static QLocale::Country codeToCountry(const QStringRef &code) Q_DECL_NOTHROW { return codeToCountry(code.data(), code.size()); }
|
||||||
static void getLangAndCountry(const QString &name, QLocale::Language &lang,
|
static void getLangAndCountry(const QString &name, QLocale::Language &lang,
|
||||||
QLocale::Script &script, QLocale::Country &cntry);
|
QLocale::Script &script, QLocale::Country &cntry);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user