Skip to content

Commit

Permalink
fix: use asKeyValueRange() instead of keys() (#159)
Browse files Browse the repository at this point in the history
improves execution speed by 16% in Debug mode :
- before : 0.054s
- after : 0.045s

Fixes: #101
  • Loading branch information
smnppKDAB authored Aug 30, 2024
1 parent 5872867 commit 4a4a73a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tools/cpp2doc/docwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
}
}
Expand Down

0 comments on commit 4a4a73a

Please sign in to comment.