Cache QUrl::idnWhiteList() absent user_idn_whitelist
Instead of creating a QStringList from a static array anew for each call, cache the result in a static variable. If we have to pay for the overhead of implicitly-shared classes, we should at least reap the benefits, too. Use IILE to gain automatic thread-safety (thread-safe statics). Change-Id: Ib92dd9cb85f84e013f98ca81565cc392bb39e76b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
565c2e8cf9
commit
ed4c1b4e90
@ -2605,13 +2605,16 @@ QStringList QUrl::idnWhitelist()
|
||||
{
|
||||
if (user_idn_whitelist)
|
||||
return *user_idn_whitelist;
|
||||
QStringList list;
|
||||
list.reserve(idn_whitelist_size);
|
||||
unsigned int i = 0;
|
||||
while (i < idn_whitelist_size) {
|
||||
list << QLatin1String(idn_whitelist[i]);
|
||||
++i;
|
||||
}
|
||||
static const QStringList list = [] {
|
||||
QStringList list;
|
||||
list.reserve(idn_whitelist_size);
|
||||
unsigned int i = 0;
|
||||
while (i < idn_whitelist_size) {
|
||||
list << QLatin1String(idn_whitelist[i]);
|
||||
++i;
|
||||
}
|
||||
return list;
|
||||
}();
|
||||
return list;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user