aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man.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 /man.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 'man.c')
-rw-r--r--man.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/man.c b/man.c
index e128d846..340402a4 100644
--- a/man.c
+++ b/man.c
@@ -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;