diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-09-16 14:40:56 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-09-16 14:40:56 +0000 |
commit | 374dd658a605a794b307642e87295f468d29d56a (patch) | |
tree | eeda12f0d84b8e08c64a3590a881d337b2a26b49 /man.c | |
parent | 6cbefd50d90dc947c06ea2212c4d3552c4a36c84 (diff) | |
download | mandoc-374dd658a605a794b307642e87295f468d29d56a.tar.gz mandoc-374dd658a605a794b307642e87295f468d29d56a.tar.zst mandoc-374dd658a605a794b307642e87295f468d29d56a.zip |
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.
Diffstat (limited to 'man.c')
-rw-r--r-- | man.c | 14 |
1 files changed, 4 insertions, 10 deletions
@@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.39 2009/08/22 09:10:38 kristaps Exp $ */ +/* $Id: man.c,v 1.40 2009/09/16 14:40:56 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -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; |