chiark / gitweb /
chain.c: Use `short' for word and chain lengths, except for QP tries.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 30 Mar 2025 20:25:58 +0000 (21:25 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 30 Mar 2025 21:48:44 +0000 (22:48 +0100)
The maximum word length is 64 bytes, and the chain length is bounded by
the word length.  We're sort-of forced into `size_t' for the word length
with QP tries, because `Tnextl' wants to store the key length through a
pointer.

chain.c

diff --git a/chain.c b/chain.c
index 77e9e638f5d17ea48e2efc40f483eac28b47f0d6..6933febccbebb16547ca40ecd30ad3295f8fbf41 100644 (file)
--- a/chain.c
+++ b/chain.c
 #  endif
 #endif
 
-struct word { const char *p; size_t n; } word;
+struct word {
+  const char *p;
+#if USE_QPTRIE
+  size_t n;
+#else
+  unsigned short n;
+#endif
+} word;
 
 struct node {
 #if USE_XYLA
@@ -185,7 +192,7 @@ struct node {
   struct word w;
 #endif
   struct node *down, *right, *up;
-  int len;
+  short len;
 };
 
 #define WORDMAX 64