From af6a4b83ebdb83f24b6913b372e207bcf245ea0c Mon Sep 17 00:00:00 2001 From: Tom Hinton Date: Thu, 1 Oct 2015 12:16:41 +0100 Subject: Make normal filtering of plain ASCII lines faster This patch adds a field lines_not_ascii to the MenuState structure. The nth entry is 0 unless the nth member of MenuState.lines has a non-ascii codepoint in it. All comparison functions (menu_match_cb type) take an additional argument to tell them if the thing they are matching is not_ascii. They can use this to determine whether to collate and case-fold the input (for non-ascii strings), or whether to use strstr/strcasestr (for ascii strings). The change is not currently implemented for flex matching, due to my laziness. However, it should be a simple enough matter to add. For my large input of 400,000 lines, this reduces typical filtering time to about ten microseconds from about 2 seconds. --- include/rofi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/rofi.h') diff --git a/include/rofi.h b/include/rofi.h index bf7ee333..1aff2350 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -78,7 +78,7 @@ typedef enum * * @returns 1 when it matches, 0 if not. */ -typedef int ( *menu_match_cb )( char **tokens, const char *input, int case_sensitive, unsigned int index, Switcher *data ); +typedef int ( *menu_match_cb )( char **tokens, const char *input, int not_ascii, int case_sensitive, unsigned int index, Switcher *data ); /** * @param sw the Switcher to show. -- cgit v1.2.3