From 4a4a73ac509734dd27a7652be452effed6586615 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 30 Aug 2024 19:26:02 +0200 Subject: [PATCH] fix: use asKeyValueRange() instead of keys() (#159) improves execution speed by 16% in Debug mode : - before : 0.054s - after : 0.045s Fixes: KDAB#101 --- tools/cpp2doc/docwriter.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/cpp2doc/docwriter.cpp b/tools/cpp2doc/docwriter.cpp index 6b1b5ec4..bed2e9d9 100644 --- a/tools/cpp2doc/docwriter.cpp +++ b/tools/cpp2doc/docwriter.cpp @@ -378,9 +378,7 @@ QString DocWriter::methodToString(const Data::QmlMethod &method, bool summary) c QString DocWriter::typeToString(QString type) const { - // Note: inefficient, but good enough for now - const auto &keys = m_typeFileMap.keys(); - for (const auto &key : keys) { + for (const auto &[key, value] : m_typeFileMap.asKeyValueRange()) { int index = type.indexOf(key); while (index != -1) { bool doContinue = false; @@ -389,7 +387,7 @@ QString DocWriter::typeToString(QString type) const if (index + key.length() < type.length() && type[index + key.length()].isLetterOrNumber()) doContinue = true; if (!doContinue) - type.replace(index, key.length(), QString("[%1](%2)").arg(key, m_typeFileMap.value(key))); + type.replace(index, key.length(), QString("[%1](%2)").arg(key, value)); index = type.indexOf(key, index + key.length()); } }