dict: lookups take a trie; a prefix search is its own function; no self-key rule

dictlookup took a Lang for two reasons that were not its business: to
know whether to walk below the key (the emoji dictionary) and to drop a
candidate equal to the key except there.  No dictionary lists its key
among its candidates — the rule was left from a first version that put
the reading first itself — so it goes, and the walk is dictprefix(),
called by the emoji search alone.
This commit is contained in:
2026-08-17 01:31:51 +09:00
parent 3d862bdc0d
commit 5faefd9a87
6 changed files with 59 additions and 51 deletions

View File

@@ -289,7 +289,7 @@ dictqokuri(Str *reading)
key = *reading;
key.n = i;
sputr(&key, c);
n = dictlookup(im.l, &key, kouho, Maxkouho);
n = dictlookup(im.l->dict, &key, kouho, Maxkouho);
sclear(&okuri);
for(j = i - (reading->r[i-1] == L''); j < reading->n; j++)
sputr(&okuri, reading->r[j]);
@@ -310,7 +310,7 @@ dictqjp(void)
if(!isjp(&im) || !jpreading(im.l->map, &im.pre, &im.raw, &reading) ||
reading.n == 0)
return;
im.nkouho = dictlookup(im.l, &reading, im.kouho, Maxkouho);
im.nkouho = dictlookup(im.l->dict, &reading, im.kouho, Maxkouho);
dictqokuri(&reading);
}
@@ -572,13 +572,13 @@ emojiquery(void)
transstr(im.l, nil, &search.raw, &local);
foldascii(&local);
clearkouho();
n = dictlookup(getlang(LangEMOJI), &raw, kouho, Maxkouho);
n = dictprefix(getlang(LangEMOJI)->dict, &raw, kouho, Maxkouho);
rawhit = n != 0;
for(i = 0; i < n; i++)
addkouho(&kouho[i]);
localhit = 0;
if(scmp(&raw, &local) != 0){
n = dictlookup(getlang(LangEMOJI), &local, kouho, Maxkouho);
n = dictprefix(getlang(LangEMOJI)->dict, &local, kouho, Maxkouho);
localhit = n != 0;
for(i = 0; i < n; i++)
addkouho(&kouho[i]);
@@ -593,8 +593,8 @@ hanjaquery(void)
{
transstr(im.l, &search.seed, &search.raw, &search.text);
clearkouho();
im.nkouho = dictlookup(getlang(LangHANJA), &search.text, im.kouho,
Maxkouho);
im.nkouho = dictlookup(getlang(LangHANJA)->dict, &search.text,
im.kouho, Maxkouho);
selectfirst();
}