diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2021-02-23 00:37:11 +0200 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2021-03-06 01:35:08 +0200 |
commit | 9d87348260316af729892c58bc29f159a173abf1 (patch) | |
tree | af81edda4bf441239f4ccc66dbfb533c5be26a47 /src/core/kconfigini.cpp | |
parent | ee35bdce8f6b08922b4c9e0c0c838e5f2c4a79ad (diff) | |
download | kconfig-9d87348260316af729892c58bc29f159a173abf1.tar.gz kconfig-9d87348260316af729892c58bc29f159a173abf1.tar.bz2 |
Minor code optimisation
- Use more range-for loops where appropriate
- Use auto instead of the usually-long iterator type names
- Use cbegin/cend(), to match the std:: containers, less confusion
- Use qDeleteAll instead of a for loop
- Make a QRE with a long-ish pattern static
NO_CHANGELOG
Diffstat (limited to 'src/core/kconfigini.cpp')
-rw-r--r-- | src/core/kconfigini.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index dd24a959..8c81db8f 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -298,8 +298,8 @@ void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file, { QByteArray currentGroup; bool groupIsImmutable = false; - const KEntryMapConstIterator end = map.constEnd(); - for (KEntryMapConstIterator it = map.constBegin(); it != end; ++it) { + const auto end = map.cend(); + for (auto it = map.cbegin(); it != end; ++it) { const KEntryKey &key = it.key(); // Either process the default group or all others @@ -746,13 +746,13 @@ public: QByteArray KConfigIniBackend::stringToPrintable(const QByteArray &aString, StringType type) { - if (aString.isEmpty()) { + const int len = aString.size(); + if (len == 0) { return aString; } - const int l = aString.length(); - QByteArray result; // Guesstimated that it's good to avoid data() initialization for a length of l*4 - result.resize(l * 4); // Maximum 4x as long as source string due to \x<ab> escape sequences + QByteArray result; // Guesstimated that it's good to avoid data() initialization for a length of len*4 + result.resize(len * 4); // Maximum 4x as long as source string due to \x<ab> escape sequences const char *s = aString.constData(); int i = 0; char *data = result.data(); @@ -766,7 +766,7 @@ QByteArray KConfigIniBackend::stringToPrintable(const QByteArray &aString, Strin } Utf8Char utf8; - for (; i < l; ++i /*, r++*/) { + for (; i < len; ++i) { switch (s[i]) { default: if (utf8.addByte(s[i])) { |