summaryrefslogtreecommitdiff
path: root/src/compgen.h
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2022-11-28 22:19:12 +0000
committerPhil Jones <philj56@gmail.com>2022-11-28 22:19:12 +0000
commit3861e8289ae40bac168275ce6f10b231e11baa55 (patch)
tree30093bb562e9718c60d3d36c9942ce4714c43488 /src/compgen.h
parent574b523ab5d9b63a114ac905e5ff8494f4b2f233 (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/compgen.h')
-rw-r--r--src/compgen.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/compgen.h b/src/compgen.h
index a80c62b..5e36576 100644
--- a/src/compgen.h
+++ b/src/compgen.h
@@ -4,8 +4,12 @@
#include "history.h"
#include "string_vec.h"
-struct string_vec compgen(void);
-struct string_vec compgen_cached(void);
-void compgen_history_sort(struct string_vec *programs, struct history *history);
+[[nodiscard("memory leaked")]]
+char *compgen(void);
+
+[[nodiscard("memory leaked")]]
+char *compgen_cached(void);
+
+void compgen_history_sort(struct string_ref_vec *programs, struct history *history);
#endif /* COMPGEN_H */