summary refs log tree commit diff
path: root/src/CompletionProxyModel.h
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2022-07-23 13:00:11 +0200
committerGitHub <noreply@github.com>2022-07-23 13:00:11 +0200
commit87365c4b5f8cd1c369ad7d3d23a423a72b7e9276 (patch)
tree5a9238e0c926af2962a5c3673f4b155a8dfef8da /src/CompletionProxyModel.h
parentUpdate clazy baseimage (diff)
parentDo less work when building completion trie (diff)
downloadnheko-87365c4b5f8cd1c369ad7d3d23a423a72b7e9276.tar.xz
Merge pull request #1126 from nenomius/master
Do less work when building completion trie
Diffstat (limited to 'src/CompletionProxyModel.h')
-rw-r--r--src/CompletionProxyModel.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/CompletionProxyModel.h b/src/CompletionProxyModel.h

index 78c7ea5f..e4a1b9cd 100644 --- a/src/CompletionProxyModel.h +++ b/src/CompletionProxyModel.h
@@ -9,12 +9,19 @@ #include <QAbstractProxyModel> +enum class ElementRank +{ + first, + second +}; + template<typename Key, typename Value> struct trie { std::vector<Value> values; std::map<Key, trie> next; + template<ElementRank r> void insert(const QVector<Key> &keys, const Value &v) { auto t = this; @@ -22,7 +29,11 @@ struct trie t = &t->next[k]; } - t->values.push_back(v); + if constexpr (r == ElementRank::first) { + t->values.insert(t->values.begin(), v); + } else if constexpr (r == ElementRank::second) { + t->values.push_back(v); + } } std::vector<Value> valuesAndSubvalues(size_t limit = -1) const