diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-01-06 03:02:46 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-01-06 03:02:46 +0000 |
commit | bde6b6e5fe1b391dac65511440cb88c4501b17c6 (patch) | |
tree | 17ffada1819d058aff1e45486983b8f68a6a2238 | |
parent | 0a8353f869e8d8e9772ef1e8e227f19a628994ad (diff) | |
download | mandoc-bde6b6e5fe1b391dac65511440cb88c4501b17c6.tar.gz |
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.
-rw-r--r-- | apropos.c | 6 | ||||
-rw-r--r-- | mandocdb.c | 15 | ||||
-rw-r--r-- | manpage.c | 5 | ||||
-rw-r--r-- | mansearch.c | 8 | ||||
-rw-r--r-- | mansearch.h | 1 |
5 files changed, 7 insertions, 28 deletions
@@ -42,7 +42,7 @@ main(int argc, char *argv[]) char *defpaths, *auxpaths; char *conf_file; char *progname; - char *outkey; + const char *outkey; extern char *optarg; extern int optind; @@ -59,7 +59,7 @@ main(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) { @@ -103,11 +103,9 @@ main(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); } @@ -1736,7 +1736,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; @@ -1747,20 +1746,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); @@ -1897,7 +1885,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" @@ -1933,7 +1920,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 (?,?,?,?,?)"; @@ -90,7 +90,7 @@ main(int argc, char *argv[]) search.deftype = TYPE_Nm | TYPE_Nd; manpath_parse(&paths, conf_file, defpaths, auxpaths); - ch = mansearch(&search, &paths, argc, argv, NULL, &res, &sz); + ch = mansearch(&search, &paths, argc, argv, "Nd", &res, &sz); manpath_free(&paths); if (0 == ch) @@ -107,9 +107,8 @@ main(int argc, char *argv[]) for (i = 0; i < sz; i++) { printf("%6zu %s: %s\n", - i + 1, res[i].names, res[i].desc); + i + 1, res[i].names, res[i].output); free(res[i].names); - free(res[i].desc); free(res[i].output); } diff --git a/mansearch.c b/mansearch.c index 7f6ec165..835cd436 100644 --- a/mansearch.c +++ b/mansearch.c @@ -70,7 +70,6 @@ struct expr { struct match { uint64_t id; /* identifier in database */ - char *desc; /* description of manpage */ int form; /* 0 == catpage */ }; @@ -279,7 +278,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); @@ -289,9 +288,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); } @@ -321,7 +318,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/mansearch.h b/mansearch.h index 1339a5de..72e0bf44 100644 --- a/mansearch.h +++ b/mansearch.h @@ -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 */ }; |