diff --git a/src/lib/data/search/SearchMatch.cpp b/src/lib/data/search/SearchMatch.cpp index 1ebd1959..0a631593 100644 --- a/src/lib/data/search/SearchMatch.cpp +++ b/src/lib/data/search/SearchMatch.cpp @@ -174,7 +174,7 @@ bool SearchMatch::operator<(const SearchMatch& other) const } } - return false; + return getSearchTypeName() < other.getSearchTypeName(); } bool SearchMatch::operator==(const SearchMatch& other) const diff --git a/src/lib/data/storage/PersistentStorage.cpp b/src/lib/data/storage/PersistentStorage.cpp index d839f2fa..e3d0491c 100644 --- a/src/lib/data/storage/PersistentStorage.cpp +++ b/src/lib/data/storage/PersistentStorage.cpp @@ -627,8 +627,10 @@ std::vector PersistentStorage::getAutocompletionMatches(const std:: utility::append(matches, getAutocompletionCommandMatches(query, acceptedNodeTypes)); // Rescore search matches to check if better score is achieved with higher indices - std::map matchesMap; - for (SearchMatch& match : matches) + std::vector rescoredMatches; + rescoredMatches.reserve(matches.size()); + + for (SearchMatch match : matches) { // rescore match if (!match.subtext.empty() && match.indices.size()) @@ -640,15 +642,15 @@ std::vector PersistentStorage::getAutocompletionMatches(const std:: match.indices = std::move(newResult.indices); } - matchesMap.emplace(match.name, match); + rescoredMatches.emplace_back(match); } // Score child symbol matches with same score as parent lower const SearchMatch* lastMatch = nullptr; std::set matchesSet; - for (auto& p : matchesMap) + + for (SearchMatch match : rescoredMatches) { - SearchMatch& match = p.second; if (lastMatch == nullptr || !utility::isPrefix(lastMatch->name, match.name)) { lastMatch = &match;