Replace a HashMap w/ a BTreeMap

The HashMap is used to generate the __fish_describe_command integration
completions. Given the nature of the allocations and the numbers that we use, a
BTreeMap would theoretically perform better. Benchmarks show a 2-9%
improvement in completion times consistently in favor of BTreeMap.
This commit is contained in:
Mahmoud Al-Qudsi 2024-08-31 14:13:41 -05:00
parent 73908f1218
commit 50a6dfd10d

View file

@ -988,7 +988,7 @@ impl<'ctx> Completer<'ctx> {
// Then discard anything that is not a possible completion and put the result into a
// hashtable with the completion as key and the description as value.
let mut lookup = HashMap::new();
let mut lookup = BTreeMap::new();
// A typical entry is the command name, followed by a tab, followed by a description.
for elstr in &mut list {
// Skip keys that are too short.