mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Optimize sort_and_prioritize_completions
Don't continuously shift items in the vector by using std::remove_if instead, followed by a single call to ->erase().
This commit is contained in:
parent
b575e120cf
commit
d9be55e504
1 changed files with 3 additions and 6 deletions
|
@ -262,12 +262,9 @@ void completions_sort_and_prioritize(std::vector<completion_t> *comps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Throw out completions whose match types are less suitable than the best.
|
// Throw out completions whose match types are less suitable than the best.
|
||||||
size_t i = comps->size();
|
comps->erase(std::remove_if(comps->begin(), comps->end(), [&] (const completion_t &comp) {
|
||||||
while (i--) {
|
return comp.match.type > best_type;
|
||||||
if (comps->at(i).match.type > best_type) {
|
}), comps->end());
|
||||||
comps->erase(comps->begin() + i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort, provided COMPLETION_DONT_SORT isn't set
|
// Sort, provided COMPLETION_DONT_SORT isn't set
|
||||||
stable_sort(comps->begin(), comps->end(), completion_t::is_naturally_less_than);
|
stable_sort(comps->begin(), comps->end(), completion_t::is_naturally_less_than);
|
||||||
|
|
Loading…
Reference in a new issue