From 6345042a457de84d0b4fdb0ffe8e21052479fdbc Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Wed, 16 Sep 2009 14:40:56 +0000 Subject: Lookup hashes are now static tables, ordered first-level by second character, then randomly along a chain. Improves performance by a small fraction and considerably cleans up hash sources. --- man.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'man.c') diff --git a/man.c b/man.c index 7e69564b..486c352f 100644 --- a/man.c +++ b/man.c @@ -105,9 +105,6 @@ man_free(struct man *man) { man_free1(man); - - if (man->htab) - man_hash_free(man->htab); free(man); } @@ -125,14 +122,11 @@ man_alloc(void *data, int pflags, const struct man_cb *cb) return(NULL); } + man_hash_init(); + p->data = data; p->pflags = pflags; (void)memcpy(&p->cb, cb, sizeof(struct man_cb)); - - if (NULL == (p->htab = man_hash_alloc())) { - free(p); - return(NULL); - } return(p); } @@ -513,7 +507,7 @@ man_pmacro(struct man *m, int ln, char *buf) return(1); } - if (MAN_MAX == (c = man_hash_find(m->htab, mac))) { + if (MAN_MAX == (c = man_hash_find(mac))) { if ( ! (MAN_IGN_MACRO & m->pflags)) { (void)man_perr(m, ln, ppos, WMACRO); goto err; -- cgit