diff options
author | David Faure <faure@kde.org> | 2021-06-23 12:34:53 +0200 |
---|---|---|
committer | David Faure <faure@kde.org> | 2021-08-03 10:01:15 +0000 |
commit | 17c179566d764d9a55b6ae98006495133bcffdbf (patch) | |
tree | c165ae4f07b8b7b1d06a2bf5200b6d9ea27f46d1 | |
parent | ed28682265bd95416a98d5ccc6a72e96563f84f3 (diff) | |
download | kconfig-17c179566d764d9a55b6ae98006495133bcffdbf.tar.gz kconfig-17c179566d764d9a55b6ae98006495133bcffdbf.tar.bz2 |
KConfig: sort keys in keyListImpl() so unittests can rely on it
The code was using a QSet (hash-based), use a std::set instead
for unicity, it gives us sorting for free.
We probably want to do the same in groupList(), but that's separate.
-rw-r--r-- | src/core/kconfig.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp index 9b8d2e62..b4777575 100644 --- a/src/core/kconfig.cpp +++ b/src/core/kconfig.cpp @@ -31,6 +31,8 @@ #include <QSet> #include <QThreadStorage> +#include <set> + #if KCONFIG_USE_DBUS #include <QDBusConnection> #include <QDBusMessage> @@ -347,14 +349,14 @@ QStringList KConfigPrivate::keyListImpl(const QByteArray &theGroup) const if (it != theEnd) { ++it; // advance past the special group entry marker - QSet<QString> tmp; + std::set<QString> tmp; // unique set, sorted for unittests for (; it != theEnd && it.key().mGroup == theGroup; ++it) { const KEntryKey &key = it.key(); if (!key.mKey.isNull() && !it->bDeleted) { - tmp << QString::fromUtf8(key.mKey); + tmp.insert(QString::fromUtf8(key.mKey)); } } - keys = tmp.values(); + keys = QList<QString>(tmp.begin(), tmp.end()); } return keys; |