summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2022-11-28 22:19:16 +0000
committerPhil Jones <philj56@gmail.com>2022-11-28 22:19:16 +0000
commitdd36bf1c53216e1828d136cb735d65816575571f (patch)
treee722af346c019942b296e5aae6e8846afb15ed67 /src/main.c
parent3861e8289ae40bac168275ce6f10b231e11baa55 (diff)
Improve performance of tofi-run history sorting.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 48de680..7a92c19 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1321,14 +1321,17 @@ int main(int argc, char *argv[])
log_debug("Generating command list.\n");
log_indent();
tofi.window.entry.command_buffer = compgen_cached();
- tofi.window.entry.commands = string_ref_vec_from_buffer(tofi.window.entry.command_buffer);
+ struct string_ref_vec commands = string_ref_vec_from_buffer(tofi.window.entry.command_buffer);
if (tofi.use_history) {
if (tofi.history_file[0] == 0) {
tofi.window.entry.history = history_load_default_file(tofi.window.entry.drun);
} else {
tofi.window.entry.history = history_load(tofi.history_file);
}
- compgen_history_sort(&tofi.window.entry.commands, &tofi.window.entry.history);
+ tofi.window.entry.commands = compgen_history_sort(&commands, &tofi.window.entry.history);
+ string_ref_vec_destroy(&commands);
+ } else {
+ tofi.window.entry.commands = commands;
}
log_unindent();
log_debug("Command list generated.\n");