From cae1e9b6d2ec957f8bc4643b898308a404d00a5f Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 23 Feb 2021 13:08:15 +0200 Subject: Add KEntryMap::constFindEntry() method - This has the same logic as QMap::constFind(); less detaching and now we can use auto keyword when creating iterators and always get a const_iterator even when calling constFindEntry() on a non-const map. - Use QCOMPARE() where appropriate in the unit tests. --- src/core/kconfig.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/core/kconfig.cpp') diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index ab6ac5c5..7f53847f 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -332,8 +332,8 @@ QStringList KConfigPrivate::keyListImpl(const QByteArray &theGroup) const { QStringList keys; - const KEntryMapConstIterator theEnd = entryMap.constEnd(); - KEntryMapConstIterator it = entryMap.findEntry(theGroup); + const auto theEnd = entryMap.constEnd(); + auto it = entryMap.constFindEntry(theGroup); if (it != theEnd) { ++it; // advance past the special group entry marker @@ -363,8 +363,8 @@ QMap KConfig::entryMap(const QString &aGroup) const QMap theMap; const QByteArray theGroup(aGroup.isEmpty() ? "" : aGroup.toUtf8()); - const KEntryMapConstIterator theEnd = d->entryMap.constEnd(); - KEntryMapConstIterator it = d->entryMap.findEntry(theGroup, {}, {}); + const auto theEnd = d->entryMap.constEnd(); + auto it = d->entryMap.constFindEntry(theGroup, {}, {}); if (it != theEnd) { ++it; // advance past the special group entry marker @@ -981,7 +981,7 @@ QByteArray KConfigPrivate::lookupData(const QByteArray &group, const char *key, if (bReadDefaults) { flags |= KEntryMap::SearchDefaults; } - const KEntryMapConstIterator it = entryMap.findEntry(group, key, flags); + const auto it = entryMap.constFindEntry(group, key, flags); if (it == entryMap.constEnd()) { return QByteArray(); } -- cgit v1.2.1