From 510b10b96b546fcc6c6b6be85050305ddd192a41 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sat, 5 Feb 2022 17:30:11 +0800 Subject: replace some hash table usage by tuples Previously I used hash tables, which consume too much memory. Now the critical parts are replaced by a new hand-written library called "tuple.h". Now we can easily parse larger inputs. I haven't tested its limits, though. --- src/ht.h | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'src/ht.h') diff --git a/src/ht.h b/src/ht.h index 65ae747..1defb53 100644 --- a/src/ht.h +++ b/src/ht.h @@ -1,5 +1,6 @@ #ifndef HT_H #define HT_H +#include "pair.h" #include "util.h" enum { HT_INIT_CAP = 1 << 8 }; @@ -117,24 +118,12 @@ P_ATTR void *ht_find(CCR_MOD(ht *) htp, void *key); /* Pairing hash tables */ -struct pair2_s { NUM x; NUM y; }; - -typedef struct pair2_s pair2; - /* On error return NULL */ ht *new_ht2(UNUM size); -struct pair3_s { NUM x; NUM y; NUM z; }; - -typedef struct pair3_s pair3; - /* On error return NULL */ ht *new_ht3(UNUM size); -struct pair4_s { NUM x; NUM y; NUM z; NUM w; }; - -typedef struct pair4_s pair4; - ht *new_ht4(UNUM size); #define NEW_P2(P, X, Y, CLEAN) do { \ @@ -155,7 +144,7 @@ ht *new_ht4(UNUM size); P->x = X; \ P->y = Y; \ P->z = Z; \ - P->w = W; \ + P->u = W; \ } while (0) #endif -- cgit v1.2.3-18-g5258