From: schwarze Date: Mon, 6 Jan 2014 22:39:19 +0000 (+0000) Subject: Another 18% speedup for mandocdb(8) -Q, found by gprof(1). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=231c70615b60941c7da3720c968c3e06a2433ef0;p=openbsd Another 18% speedup for mandocdb(8) -Q, found by gprof(1). In -Q mode, refrain form validating and normalizing the format of the date given in .Dd or .TH, as it won't be used anyway. For /usr/share/man, mandocdb -Q now takes 45% of the time of makewhatis(8). --- diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c index 54a4f5acdfc..b1031376ded 100644 --- a/usr.bin/mandoc/man_validate.c +++ b/usr.bin/mandoc/man_validate.c @@ -1,7 +1,7 @@ -/* $Id: man_validate.c,v 1.59 2013/12/31 18:07:06 schwarze Exp $ */ +/* $Id: man_validate.c,v 1.60 2014/01/06 22:39:19 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2010, 2012, 2013 Ingo Schwarze + * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -207,8 +207,8 @@ check_root(CHKARGS) man->meta.title = mandoc_strdup("unknown"); man->meta.msec = mandoc_strdup("1"); - man->meta.date = mandoc_normdate - (man->parse, NULL, n->line, n->pos); + man->meta.date = man->quick ? mandoc_strdup("") : + mandoc_normdate(man->parse, NULL, n->line, n->pos); } return(1); @@ -431,8 +431,10 @@ post_TH(CHKARGS) if (n) n = n->next; if (n && n->string && '\0' != n->string[0]) { - man->meta.date = mandoc_normdate - (man->parse, n->string, n->line, n->pos); + man->meta.date = man->quick ? + mandoc_strdup(n->string) : + mandoc_normdate(man->parse, n->string, + n->line, n->pos); } else man->meta.date = mandoc_strdup(""); diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index aeea0440a5b..ec94325f88c 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,7 +1,7 @@ -/* $Id: mdoc_validate.c,v 1.117 2014/01/06 00:53:14 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.118 2014/01/06 22:39:19 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons - * Copyright (c) 2010, 2011, 2012, 2013 Ingo Schwarze + * Copyright (c) 2010-2014 Ingo Schwarze * Copyright (c) 2010 Joerg Sonnenberger * * Permission to use, copy, modify, and distribute this software for any @@ -2180,8 +2180,8 @@ post_dd(POST_ARGS) n = mdoc->last; if (NULL == n->child || '\0' == n->child->string[0]) { - mdoc->meta.date = mandoc_normdate - (mdoc->parse, NULL, n->line, n->pos); + mdoc->meta.date = mdoc->quick ? mandoc_strdup("") : + mandoc_normdate(mdoc->parse, NULL, n->line, n->pos); return(1); } @@ -2192,8 +2192,8 @@ post_dd(POST_ARGS) } assert(c); - mdoc->meta.date = mandoc_normdate - (mdoc->parse, buf, n->line, n->pos); + mdoc->meta.date = mdoc->quick ? mandoc_strdup(buf) : + mandoc_normdate(mdoc->parse, buf, n->line, n->pos); return(1); }