From 3861e8289ae40bac168275ce6f10b231e11baa55 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Mon, 28 Nov 2022 22:19:12 +0000 Subject: Refactor string vector code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, string vectors were built by reading input line-by line, and multiple copies of string vectors were made when searching. Now, input is read into one big buffer, and string vectors only contain references to the strings in this buffer. This both speeds up reading of input, and avoids unnecessary copying of strings in various places. The main downside currently is that input read from stdin is no longer UTF-8 normalised. This means, for example, that a search for `e` won't necessarily match `é`. Normalisation is very slow relative to the rest of tofi, however, and not needed for most use-cases. This could either be solved by accepting the slowdown, or making this an option, such as --unicode or --unicode-normalize. --- src/entry.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/entry.h') diff --git a/src/entry.h b/src/entry.h index a9353a5..4ee6316 100644 --- a/src/entry.h +++ b/src/entry.h @@ -55,8 +55,9 @@ struct entry { uint32_t selection; uint32_t first_result; - struct string_vec results; - struct string_vec commands; + char *command_buffer; + struct string_ref_vec results; + struct string_ref_vec commands; struct desktop_vec apps; struct history history; bool use_pango; -- cgit v1.2.3