diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-04-09 21:50:08 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-04-09 21:50:08 +0000 |
commit | 31583f54660e373832d0fc36eaa2005e7e836229 (patch) | |
tree | 2072a99b38e5cf05716e1f1095798bb83e42d033 /mandocdb.c | |
parent | b89bb1378a92c68b93b6d3450cbda691e289d6c6 (diff) | |
download | mandoc-31583f54660e373832d0fc36eaa2005e7e836229.tar.gz |
After careful gprof(1)ing of the new apropos(1), move the descriptions
back from the keys table to the mpages table: I found a good way
to still use them in searches, without complication of the code.
On my notebook, this reduces typical apropos(1) search times by about 40%,
it reduces /usr/share/man database size by 6% in makewhatis(8) -Q mode
and by 2% in standard mode (less overhead storing pointers to mpages),
and it doesn't measurably change database build times (may even be
going down by a percent or so because less data is being copied
around in ohashes).
Diffstat (limited to 'mandocdb.c')
-rw-r--r-- | mandocdb.c | 25 |
1 files changed, 8 insertions, 17 deletions
@@ -224,7 +224,7 @@ static const struct mdoc_handler mdocs[MDOC_MAX] = { { NULL, TYPE_Ic }, /* Ic */ { NULL, TYPE_In }, /* In */ { NULL, TYPE_Li }, /* Li */ - { parse_mdoc_Nd, TYPE_Nd }, /* Nd */ + { parse_mdoc_Nd, 0 }, /* Nd */ { parse_mdoc_Nm, 0 }, /* Nm */ { NULL, 0 }, /* Op */ { NULL, 0 }, /* Ot */ @@ -1154,8 +1154,9 @@ mpages_merge(struct mchars *mc, struct mparse *mp) putkey(mpage, cp, TYPE_Nm); assert(NULL == mpage->desc); parse_mdoc(mpage, mdoc_node(mdoc)); - putkey(mpage, NULL != mpage->desc ? - mpage->desc : mpage->mlinks->name, TYPE_Nd); + if (NULL == mpage->desc) + mpage->desc = mandoc_strdup( + mpage->mlinks->name); } else if (NULL != man) parse_man(mpage, man_node(man)); else @@ -1298,7 +1299,6 @@ parse_cat(struct mpage *mpage, int fd) "Cannot find NAME section"); assert(NULL == mpage->desc); mpage->desc = mandoc_strdup(mpage->mlinks->name); - putkey(mpage, mpage->mlinks->name, TYPE_Nd); fclose(stream); free(title); return; @@ -1339,7 +1339,6 @@ parse_cat(struct mpage *mpage, int fd) assert(NULL == mpage->desc); mpage->desc = mandoc_strdup(p); - putkey(mpage, mpage->desc, TYPE_Nd); fclose(stream); free(title); } @@ -1480,7 +1479,6 @@ parse_man(struct mpage *mpage, const struct man_node *n) assert(NULL == mpage->desc); mpage->desc = mandoc_strdup(start); - putkey(mpage, mpage->desc, TYPE_Nd); free(title); return; } @@ -1928,16 +1926,7 @@ dbadd(struct mpage *mpage, struct mchars *mc) if (NULL != mlink) fputs(", ", stdout); } - for (key = ohash_first(&strings, &slot); NULL != key; - key = ohash_next(&strings, &slot)) { - if (TYPE_Nd & key->mask) { - if (NULL == key->rendered) - render_key(mc, key); - printf(" - %s", key->rendered); - break; - } - } - putchar('\n'); + printf(" - %s\n", mpage->desc); return; } @@ -1945,6 +1934,7 @@ dbadd(struct mpage *mpage, struct mchars *mc) say(mlink->file, "Adding to database"); i = 1; + SQL_BIND_TEXT(stmts[STMT_INSERT_PAGE], i, mpage->desc); SQL_BIND_INT(stmts[STMT_INSERT_PAGE], i, FORM_SRC == mpage->form); SQL_STEP(stmts[STMT_INSERT_PAGE]); mpage->recno = sqlite3_last_insert_rowid(db); @@ -2157,6 +2147,7 @@ dbopen(int real) create_tables: sql = "CREATE TABLE \"mpages\" (\n" + " \"desc\" TEXT NOT NULL,\n" " \"form\" INTEGER NOT NULL,\n" " \"id\" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL\n" ");\n" @@ -2189,7 +2180,7 @@ prepare_statements: "sec=? AND arch=? AND name=?)"; sqlite3_prepare_v2(db, sql, -1, &stmts[STMT_DELETE_PAGE], NULL); sql = "INSERT INTO mpages " - "(form) VALUES (?)"; + "(desc,form) VALUES (?,?)"; sqlite3_prepare_v2(db, sql, -1, &stmts[STMT_INSERT_PAGE], NULL); sql = "INSERT INTO mlinks " "(sec,arch,name,pageid) VALUES (?,?,?,?)"; |