aboutsummaryrefslogtreecommitdiffstats
path: root/util.h
diff options
context:
space:
mode:
authorNRK <nrk@disroot.org>2023-07-07 13:00:42 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2023-07-07 15:03:57 +0200
commit7ab0cb5ef0e19352fc5d64ae0d57a5cf4540acbf (patch)
tree9d68f06933733c75cceca65a19f1a16501946327 /util.h
parent0fe460dbd469a1d5b6a7140d0e1801935e4a923b (diff)
downloaddmenu-7ab0cb5ef0e19352fc5d64ae0d57a5cf4540acbf.tar.zst
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.
Diffstat (limited to 'util.h')
-rw-r--r--util.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/util.h b/util.h
index f633b51..c0a50d4 100644
--- a/util.h
+++ b/util.h
@@ -3,6 +3,7 @@
#define MAX(A, B) ((A) > (B) ? (A) : (B))
#define MIN(A, B) ((A) < (B) ? (A) : (B))
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
+#define LENGTH(X) (sizeof (X) / sizeof (X)[0])
void die(const char *fmt, ...);
void *ecalloc(size_t nmemb, size_t size);