Implement regetrank that might work

This commit is contained in:
Nishi 2026-06-24 12:27:46 +09:00
commit 871a152b12
5 changed files with 32 additions and 14 deletions

View file

@ -138,6 +138,7 @@ regetrank(SJ4_CONTEXT2) {
nkhcount = tmp = 0;
}
#if 0
for(count = khcount, kptr = kouhotbl; count--; kptr++) {
if(!(kptr->rank)) {
@ -150,4 +151,21 @@ regetrank(SJ4_CONTEXT2) {
else if((short)kptr->rank >= nrank)
kptr->rank += (u_char)nkhcount;
}
#else
while(1) {
KHREC* best = NULL;
for(count = khcount, kptr = kouhotbl; count--; kptr++) {
if(kptr->rank != 0) continue;
if(best == NULL || kptr->cost < best->cost) {
best = kptr;
}
}
if(best == NULL) break;
best->rank = trank++;
}
#endif
}