summaryrefslogtreecommitdiffstatshomepage
path: root/mdoc.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-09-16 14:40:56 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-09-16 14:40:56 +0000
commit374dd658a605a794b307642e87295f468d29d56a (patch)
treeeeda12f0d84b8e08c64a3590a881d337b2a26b49 /mdoc.c
parent6cbefd50d90dc947c06ea2212c4d3552c4a36c84 (diff)
downloadmandoc-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.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/mdoc.c b/mdoc.c
index 9b6e6724..1d63fb83 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -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);