From 50a6dfd10d429c02a9571b608c51b0e6ce5b8862 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sat, 31 Aug 2024 14:13:41 -0500 Subject: [PATCH] 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. --- src/complete.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/complete.rs b/src/complete.rs index 26bf5467b..cc13efc31 100644 --- a/src/complete.rs +++ b/src/complete.rs @@ -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.