summaryrefslogtreecommitdiff
path: root/supervisor
diff options
context:
space:
mode:
authorTaku Fukada <naninunenor@gmail.com>2020-09-14 01:25:13 +0900
committerTaku Fukada <naninunenor@gmail.com>2020-09-14 01:50:01 +0900
commitd18d79ac4709364c2371e2eaefd8f96bb20802e7 (patch)
tree1f02e0dcc5575f87cbefb37bb760c08a9b8d10d0 /supervisor
parent15964a4750d9eb1a34317c166d9bde5f40c9878d (diff)
Small improvements to the dictionary compression
Diffstat (limited to 'supervisor')
-rw-r--r--supervisor/shared/translate.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/supervisor/shared/translate.c b/supervisor/shared/translate.c
index cc0de7f61..44544c98d 100644
--- a/supervisor/shared/translate.c
+++ b/supervisor/shared/translate.c
@@ -48,17 +48,17 @@ STATIC int put_utf8(char *buf, int u) {
*buf = u;
return 1;
} else if(word_start <= u && u <= word_end) {
- int n = (u - 0x80);
- size_t off = 0;
- for(int i=0; i<n; i++) {
- off += wlen[i];
+ uint n = (u - word_start);
+ size_t pos = 0;
+ if (n > 0) {
+ pos = wends[n - 1] + (n * 2);
}
int ret = 0;
// note that at present, entries in the words table are
// guaranteed not to represent words themselves, so this adds
// at most 1 level of recursive call
- for(int i=0; i<wlen[n]; i++) {
- int len = put_utf8(buf, words[off+i]);
+ for(; pos < wends[n] + (n + 1) * 2; pos++) {
+ int len = put_utf8(buf, words[pos]);
buf += len;
ret += len;
}