From 708a1a87fa8ee04a98a18d6ae3e3552cfd2a2579 Mon Sep 17 00:00:00 2001 From: schwarze Date: Mon, 6 Jan 2014 03:02:39 +0000 Subject: [PATCH] Drop Nd from the mpages table, it is still in the keys table. This shrinks the database in standard mode by 3%, in -Q mode by 9%, without loss of functionality. --- usr.bin/mandoc/apropos.c | 8 +++----- usr.bin/mandoc/mandocdb.c | 17 ++--------------- usr.bin/mandoc/mansearch.c | 10 +++------- usr.bin/mandoc/mansearch.h | 3 +-- 4 files changed, 9 insertions(+), 29 deletions(-) diff --git a/usr.bin/mandoc/apropos.c b/usr.bin/mandoc/apropos.c index ecce6dcc9c5..80f3a5a94cb 100644 --- a/usr.bin/mandoc/apropos.c +++ b/usr.bin/mandoc/apropos.c @@ -1,4 +1,4 @@ -/* $Id: apropos.c,v 1.19 2013/12/31 03:41:09 schwarze Exp $ */ +/* $Id: apropos.c,v 1.20 2014/01/06 03:02:39 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons * Copyright (c) 2013 Ingo Schwarze @@ -39,7 +39,7 @@ apropos(int argc, char *argv[]) char *defpaths, *auxpaths; char *conf_file; char *progname; - char *outkey; + const char *outkey; extern char *optarg; extern int optind; @@ -56,7 +56,7 @@ apropos(int argc, char *argv[]) auxpaths = defpaths = NULL; conf_file = NULL; - outkey = NULL; + outkey = "Nd"; while (-1 != (ch = getopt(argc, argv, "C:M:m:O:S:s:"))) switch (ch) { @@ -100,11 +100,9 @@ apropos(int argc, char *argv[]) for (i = 0; i < sz; i++) { printf("%s - %s\n", res[i].names, - NULL == outkey ? res[i].desc : NULL == res[i].output ? "" : res[i].output); free(res[i].file); free(res[i].names); - free(res[i].desc); free(res[i].output); } diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c index eb239764af4..0d398627573 100644 --- a/usr.bin/mandoc/mandocdb.c +++ b/usr.bin/mandoc/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.59 2014/01/05 20:26:27 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.60 2014/01/06 03:02:40 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze @@ -1728,7 +1728,6 @@ dbindex(const struct mpage *mpage, struct mchars *mc) { struct mlink *mlink; struct str *key; - const char *desc; int64_t recno; size_t i; unsigned int slot; @@ -1739,20 +1738,9 @@ dbindex(const struct mpage *mpage, struct mchars *mc) if (nodb) return; - desc = ""; - if (NULL != mpage->desc && '\0' != *mpage->desc) { - key = ohash_find(&strings, - ohash_qlookup(&strings, mpage->desc)); - assert(NULL != key); - if (NULL == key->rendered) - render_key(mc, key); - desc = key->rendered; - } - SQL_EXEC("BEGIN TRANSACTION"); i = 1; - SQL_BIND_TEXT(stmts[STMT_INSERT_PAGE], i, desc); SQL_BIND_INT(stmts[STMT_INSERT_PAGE], i, FORM_SRC == mpage->form); SQL_STEP(stmts[STMT_INSERT_PAGE]); recno = sqlite3_last_insert_rowid(db); @@ -1889,7 +1877,6 @@ dbopen(int real) } sql = "CREATE TABLE \"mpages\" (\n" - " \"desc\" TEXT NOT NULL,\n" " \"form\" INTEGER NOT NULL,\n" " \"id\" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL\n" ");\n" @@ -1925,7 +1912,7 @@ prepare_statements: sql = "DELETE FROM mpages where file=?"; sqlite3_prepare_v2(db, sql, -1, &stmts[STMT_DELETE_PAGE], NULL); sql = "INSERT INTO mpages " - "(desc,form) VALUES (?,?)"; + "(form) VALUES (?)"; sqlite3_prepare_v2(db, sql, -1, &stmts[STMT_INSERT_PAGE], NULL); sql = "INSERT INTO mlinks " "(file,sec,arch,name,pageid) VALUES (?,?,?,?,?)"; diff --git a/usr.bin/mandoc/mansearch.c b/usr.bin/mandoc/mansearch.c index a09200b82c3..aa67ae9955c 100644 --- a/usr.bin/mandoc/mansearch.c +++ b/usr.bin/mandoc/mansearch.c @@ -1,4 +1,4 @@ -/* $Id: mansearch.c,v 1.8 2014/01/05 04:13:46 schwarze Exp $ */ +/* $Id: mansearch.c,v 1.9 2014/01/06 03:02:40 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons * Copyright (c) 2013, 2014 Ingo Schwarze @@ -62,7 +62,6 @@ struct expr { struct match { uint64_t id; /* identifier in database */ - char *desc; /* description of manpage */ int form; /* 0 == catpage */ }; @@ -271,7 +270,7 @@ mansearch(const struct mansearch *search, * distribution of buckets in the table. */ while (SQLITE_ROW == (c = sqlite3_step(s))) { - id = sqlite3_column_int64(s, 2); + id = sqlite3_column_int64(s, 1); idx = ohash_lookup_memory (&htab, (char *)&id, sizeof(uint64_t), (uint32_t)id); @@ -281,9 +280,7 @@ mansearch(const struct mansearch *search, mp = mandoc_calloc(1, sizeof(struct match)); mp->id = id; - mp->desc = mandoc_strdup - ((char *)sqlite3_column_text(s, 0)); - mp->form = sqlite3_column_int(s, 1); + mp->form = sqlite3_column_int(s, 0); ohash_insert(&htab, idx, mp); } @@ -313,7 +310,6 @@ mansearch(const struct mansearch *search, (*res, maxres * sizeof(struct manpage)); } mpage = *res + cur; - mpage->desc = mp->desc; mpage->form = mp->form; buildnames(mpage, db, s, mp->id, paths->paths[i]); mpage->output = outbit ? diff --git a/usr.bin/mandoc/mansearch.h b/usr.bin/mandoc/mansearch.h index 913e5be902d..1960a9cb5be 100644 --- a/usr.bin/mandoc/mansearch.h +++ b/usr.bin/mandoc/mansearch.h @@ -1,4 +1,4 @@ -/* $Id: mansearch.h,v 1.3 2014/01/05 00:29:49 schwarze Exp $ */ +/* $Id: mansearch.h,v 1.4 2014/01/06 03:02:40 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons * Copyright (c) 2013 Ingo Schwarze @@ -66,7 +66,6 @@ __BEGIN_DECLS struct manpage { char *file; /* to be prefixed by manpath */ char *names; /* a list of names with sections */ - char *desc; /* description of manpage */ char *output; /* user-defined additional output */ int form; /* 0 == catpage */ }; -- 2.20.1