diff options
author | Tom Hinton <tom.hinton@cse.org.uk> | 2015-10-01 12:16:41 +0100 |
---|---|---|
committer | Tom Hinton <tom.hinton@cse.org.uk> | 2015-10-01 12:16:41 +0100 |
commit | af6a4b83ebdb83f24b6913b372e207bcf245ea0c (patch) | |
tree | f55afd8e2ccadb7829900d9d14eebc78e48a3b53 /include/helper.h | |
parent | 574bf2da828b4e3ab0ce3ce7fccd58879db60430 (diff) |
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.
Diffstat (limited to 'include/helper.h')
-rw-r--r-- | include/helper.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/include/helper.h b/include/helper.h index 6d6f1826..d75bfe35 100644 --- a/include/helper.h +++ b/include/helper.h @@ -102,7 +102,7 @@ int find_arg ( const char * const key ); * * @returns 1 when matches, 0 otherwise */ -int token_match ( char **tokens, const char *input, int case_sensitive, +int token_match ( char **tokens, const char *input, int not_ascii, int case_sensitive, __attribute__( ( unused ) ) unsigned int index, __attribute__( ( unused ) ) Switcher * data ); @@ -152,4 +152,11 @@ char helper_parse_char ( const char *arg ); * Set the application arguments. */ void cmd_set_arguments ( int argc, char **argv ); + +/** + * @param str a UTF8 string + * @return 1 if the string contains any non-ascii codepoints + */ +int is_not_ascii ( const char *str ); + #endif // ROFI_HELPER_H |