aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKevin Funk <kfunk@kde.org>2016-02-19 00:53:48 +0100
committerKevin Funk <kfunk@kde.org>2016-02-19 00:55:07 +0100
commitd9b3ce9038ed83d4967eb9a5111d57f6081a1394 (patch)
treeaee62edf1423f9cef1fe3b39df0567cb79ecdbd7 /src
parent97190f92c27932134b4045a9c71e764cb1081394 (diff)
downloadkconfig-d9b3ce9038ed83d4967eb9a5111d57f6081a1394.tar.gz
kconfig-d9b3ce9038ed83d4967eb9a5111d57f6081a1394.tar.bz2
KConfigIniBackend: Fix expensive detach in lookup
Differential Revision: https://phabricator.kde.org/D990
Diffstat (limited to 'src')
-rw-r--r--src/core/kconfigini.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp
index 83a6c3cf..3d0af962 100644
--- a/src/core/kconfigini.cpp
+++ b/src/core/kconfigini.cpp
@@ -46,11 +46,12 @@ KCONFIGCORE_EXPORT bool kde_kiosk_exception = false; // flag to disable kiosk re
static QByteArray lookup(const KConfigIniBackend::BufferFragment &fragment, QHash<KConfigIniBackend::BufferFragment, QByteArray> *cache)
{
- QHash<KConfigIniBackend::BufferFragment, QByteArray>::iterator it = cache->find(fragment);
- if (it == cache->end()) {
- it = cache->insert(fragment, fragment.toByteArray());
+ auto it = cache->constFind(fragment);
+ if (it != cache->constEnd()) {
+ return it.value();
}
- return it.value();
+
+ return cache->insert(fragment, fragment.toByteArray()).value();
}
QString KConfigIniBackend::warningProlog(const QFile &file, int line)