diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2022-02-07 00:21:12 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2022-02-07 00:21:12 +0100 |
commit | eb96af27f4059c93d7e000e910b71d74829a239b (patch) | |
tree | 88a2f3b878606c0de8f08f0b355c1eba55317ef3 | |
parent | d78ff08d99780a73447d5a95bf1e358e8c23aa3c (diff) |
improve performance of case-insensitive matching
-rw-r--r-- | dmenu.c | 13 |
1 files changed, 1 insertions, 12 deletions
@@ -102,17 +102,6 @@ cleanup(void) | |||
102 | XCloseDisplay(dpy); | 102 | XCloseDisplay(dpy); |
103 | } | 103 | } |
104 | 104 | ||
105 | static char * | ||
106 | cistrstr(const char *s, const char *sub) | ||
107 | { | ||
108 | size_t len; | ||
109 | |||
110 | for (len = strlen(sub); *s; s++) | ||
111 | if (!strncasecmp(s, sub, len)) | ||
112 | return (char *)s; | ||
113 | return NULL; | ||
114 | } | ||
115 | |||
116 | static int | 105 | static int |
117 | drawitem(struct item *item, int x, int y, int w) | 106 | drawitem(struct item *item, int x, int y, int w) |
118 | { | 107 | { |
@@ -722,7 +711,7 @@ main(int argc, char *argv[]) | |||
722 | fast = 1; | 711 | fast = 1; |
723 | else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ | 712 | else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ |
724 | fstrncmp = strncasecmp; | 713 | fstrncmp = strncasecmp; |
725 | fstrstr = cistrstr; | 714 | fstrstr = strcasestr; |
726 | } else if (i + 1 == argc) | 715 | } else if (i + 1 == argc) |
727 | usage(); | 716 | usage(); |
728 | /* these options take one argument */ | 717 | /* these options take one argument */ |