QUrlQuery: fix a very expensive always-true check

In a non-const function, if (d), d being a QSharedDataPointer,
will resolve to if(d.data()), which detaches and returns a
pointer to an unshared copy of the data. Thus, the test if (d)
is always true.

Fix by explicit use of constData(), as in other QUrlQuery
functions.

Change-Id: Ib926abdcdb069d69e34c3202c4cf451b7fc6a329
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
bb10
Marc Mutz 2015-12-30 02:30:34 +01:00
parent 5c81863019
commit 96dc9a19ae
1 changed files with 1 additions and 1 deletions

View File

@ -733,7 +733,7 @@ QStringList QUrlQuery::allQueryItemValues(const QString &key, QUrl::ComponentFor
*/
void QUrlQuery::removeQueryItem(const QString &key)
{
if (d) {
if (d.constData()) {
Map::iterator it = d->findKey(key);
if (it != d->itemList.end())
d->itemList.erase(it);