From 7ab0cb5ef0e19352fc5d64ae0d57a5cf4540acbf Mon Sep 17 00:00:00 2001 From: NRK Date: Fri, 7 Jul 2023 17:00:42 +0600 Subject: drw: minor improvement to the nomatches cache 1. use `unsigned int` to store the codepoints, this avoids waste on common case where `long` is 64bits. and POSIX guarantees `int` to be at least 32bits so there's no risk of truncation. 2. since switching to `unsigned int` cuts down the memory requirement by half, double the cache size from 64 to 128. 3. instead of a linear search, use a simple hash-table for O(1) lookups. --- dmenu.c | 1 - 1 file changed, 1 deletion(-) (limited to 'dmenu.c') diff --git a/dmenu.c b/dmenu.c index 62f1089..40f93e0 100644 --- a/dmenu.c +++ b/dmenu.c @@ -22,7 +22,6 @@ /* macros */ #define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \ * MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org))) -#define LENGTH(X) (sizeof X / sizeof X[0]) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) /* enums */ -- cgit v1.2.3