Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
stop using trie tree-based reader table
Browse files Browse the repository at this point in the history
  • Loading branch information
nyuichi committed Jan 22, 2015
1 parent 1ff8672 commit 8c67ad8
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 261 deletions.
18 changes: 0 additions & 18 deletions extlib/benz/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,21 +510,6 @@ gc_mark(pic_state *pic, pic_value v)
gc_mark_object(pic, obj);
}

static void
gc_mark_trie(pic_state *pic, struct pic_trie *trie)
{
size_t i;

for (i = 0; i < sizeof trie->table / sizeof(struct pic_trie *); ++i) {
if (trie->table[i] != NULL) {
gc_mark_trie(pic, trie->table[i]);
}
}
if (trie->proc != NULL) {
gc_mark_object(pic, (struct pic_object *)trie->proc);
}
}

#define M(x) gc_mark_object(pic, (struct pic_object *)pic->x)

static void
Expand Down Expand Up @@ -606,9 +591,6 @@ gc_mark_phase(pic_state *pic)
/* features */
gc_mark(pic, pic->features);

/* readers */
gc_mark_trie(pic, pic->reader->trie);

/* library table */
gc_mark(pic, pic->libs);

Expand Down
23 changes: 7 additions & 16 deletions extlib/benz/include/picrin/read.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,20 @@
extern "C" {
#endif

enum pic_typecase {
PIC_CASE_DEFAULT,
PIC_CASE_FOLD,
};

struct pic_trie {
struct pic_trie *table[256];
struct pic_proc *proc;
};
typedef pic_value (*pic_reader_t)(pic_state *, struct pic_port *port, int c);

struct pic_reader {
short typecase;
enum pic_typecase {
PIC_CASE_DEFAULT,
PIC_CASE_FOLD,
} typecase;
xhash labels;
struct pic_trie *trie;
pic_reader_t table[256];
pic_reader_t dispatch[256];
};

void pic_init_reader(pic_state *);

void pic_define_reader(pic_state *, const char *, pic_func_t);

struct pic_trie *pic_make_trie(pic_state *);
void pic_trie_delete(pic_state *, struct pic_trie *);

#if defined(__cplusplus)
}
#endif
Expand Down

0 comments on commit 8c67ad8

Please sign in to comment.