From dd36bf1c53216e1828d136cb735d65816575571f Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Mon, 28 Nov 2022 22:19:16 +0000 Subject: Improve performance of tofi-run history sorting. --- src/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/main.c') 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"); -- cgit v1.2.3