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/desktop_vec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/desktop_vec.h') diff --git a/src/desktop_vec.h b/src/desktop_vec.h index 760db30..f8d0b79 100644 --- a/src/desktop_vec.h +++ b/src/desktop_vec.h @@ -34,7 +34,7 @@ void desktop_vec_add_file(struct desktop_vec *desktop, const char *id, const cha void desktop_vec_sort(struct desktop_vec *restrict vec); struct desktop_entry *desktop_vec_find_sorted(struct desktop_vec *restrict vec, const char *name); -struct string_vec desktop_vec_filter( +struct string_ref_vec desktop_vec_filter( const struct desktop_vec *restrict vec, const char *restrict substr, bool fuzzy); -- cgit v1.2.3