summaryrefslogtreecommitdiffstats
path: root/source/dialogs/combi.c
diff options
context:
space:
mode:
authorTom Hinton <tom.hinton@cse.org.uk>2015-10-01 12:16:41 +0100
committerTom Hinton <tom.hinton@cse.org.uk>2015-10-01 12:16:41 +0100
commitaf6a4b83ebdb83f24b6913b372e207bcf245ea0c (patch)
treef55afd8e2ccadb7829900d9d14eebc78e48a3b53 /source/dialogs/combi.c
parent574bf2da828b4e3ab0ce3ce7fccd58879db60430 (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 'source/dialogs/combi.c')
-rw-r--r--source/dialogs/combi.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c
index 1002de08..8f67cd2f 100644
--- a/source/dialogs/combi.c
+++ b/source/dialogs/combi.c
@@ -169,7 +169,7 @@ static SwitcherMode combi_mode_result ( int mretv, char **input, unsigned int se
}
return MODE_EXIT;
}
-static int combi_mode_match ( char **tokens, const char *input,
+static int combi_mode_match ( char **tokens, const char *input, int not_ascii,
int case_sensitive, unsigned int index, Switcher *sw )
{
CombiModePrivateData *pd = sw->private_data;
@@ -178,13 +178,13 @@ static int combi_mode_match ( char **tokens, const char *input,
if ( index >= pd->starts[i] && index < ( pd->starts[i] + pd->lengths[i] ) ) {
if ( tokens && input[0] && tokens[0][0] == '!' ) {
if ( tokens[0][1] == pd->switchers[i]->name[0] ) {
- return pd->switchers[i]->token_match ( &tokens[1], input, case_sensitive,
+ return pd->switchers[i]->token_match ( &tokens[1], input, not_ascii, case_sensitive,
index - pd->starts[i], pd->switchers[i] );
}
return 0;
}
else {
- return pd->switchers[i]->token_match ( tokens, input, case_sensitive,
+ return pd->switchers[i]->token_match ( tokens, input, not_ascii, case_sensitive,
index - pd->starts[i], pd->switchers[i] );
}
}