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 /mdoc.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 'mdoc.c')
-rw-r--r-- | mdoc.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.104 2009/08/22 08:56:16 kristaps Exp $ */ +/* $Id: mdoc.c,v 1.105 2009/09/16 14:40:56 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -230,8 +230,6 @@ mdoc_free(struct mdoc *mdoc) { mdoc_free1(mdoc); - if (mdoc->htab) - mdoc_hash_free(mdoc->htab); free(mdoc); } @@ -249,13 +247,12 @@ mdoc_alloc(void *data, int pflags, const struct mdoc_cb *cb) if (cb) (void)memcpy(&p->cb, cb, sizeof(struct mdoc_cb)); + mdoc_hash_init(); + p->data = data; p->pflags = pflags; - if (NULL == (p->htab = mdoc_hash_alloc())) { - free(p); - return(NULL); - } else if (mdoc_alloc1(p)) + if (mdoc_alloc1(p)) return(p); free(p); @@ -725,7 +722,7 @@ parsemacro(struct mdoc *m, int ln, char *buf) return(1); } - if (MDOC_MAX == (c = mdoc_hash_find(m->htab, mac))) { + if (MDOC_MAX == (c = mdoc_hash_find(mac))) { if ( ! macrowarn(m, ln, mac)) goto err; return(1); |