From ca6b0d72aca18253699dafb3bf501c84023e5cc0 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Mon, 7 Feb 2022 00:21:12 +0100 Subject: [PATCH] improve performance of case-insensitive matching --- dmenu.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/dmenu.c b/dmenu.c index 4bcc952..c62d178 100644 --- a/dmenu.c +++ b/dmenu.c @@ -112,17 +112,6 @@ cleanup(void) XCloseDisplay(dpy); } -static char * -cistrstr(const char *s, const char *sub) -{ - size_t len; - - for (len = strlen(sub); *s; s++) - if (!strncasecmp(s, sub, len)) - return (char *)s; - return NULL; -} - static int drawitem(struct item *item, int x, int y, int w) { @@ -748,6 +737,8 @@ main(int argc, char *argv[]) else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */ centered = 1; else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching -- only for compatibility with scripts that uses this flag (in this build case-insensitive is the default) */ + fstrncmp = strncasecmp; + fstrstr = strcasestr; } else if (!strcmp(argv[i], "-s")) { /* case-sensitive item matching */ fstrncmp = strncmp;