use trie for map lookup

This commit is contained in:
2026-02-08 16:36:59 +09:00
parent 97f897755f
commit 5653298bb1
4 changed files with 190 additions and 80 deletions

22
dat.h
View File

@@ -45,7 +45,6 @@ typedef struct Emit Emit;
struct Emit
{
int eat;
int flush;
Str s;
Str next;
Str dict;
@@ -62,6 +61,25 @@ struct Hnode
int vlen;
};
typedef struct Tnode Tnode;
struct Tnode
{
int child;
int sibling;
char c;
char *val;
int vlen;
};
typedef struct Trie Trie;
struct Trie
{
int root;
Tnode *nodes;
int n;
int cap;
};
typedef struct Hmap Hmap;
struct Hmap
{
@@ -79,7 +97,7 @@ struct Lang
int lang;
char *mapname;
char *dictname;
Hmap *map;
Trie *map;
Hmap *dict;
};