diff options
author | Phil Jones <philj56@gmail.com> | 2022-11-28 22:19:12 +0000 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2022-11-28 22:19:12 +0000 |
commit | 3861e8289ae40bac168275ce6f10b231e11baa55 (patch) | |
tree | 30093bb562e9718c60d3d36c9942ce4714c43488 /src/desktop_vec.h | |
parent | 574b523ab5d9b63a114ac905e5ff8494f4b2f233 (diff) |
Refactor string vector code.
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.
Diffstat (limited to 'src/desktop_vec.h')
-rw-r--r-- | src/desktop_vec.h | 2 |
1 files changed, 1 insertions, 1 deletions
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); |