From dd6af3dee58be71cfea87254246a9a151552a3cb Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Sun, 28 Nov 2021 23:46:24 +0800 Subject: [PATCH] fix(dictionary): had unsorted chunks after the previous chunk ended Fixes #507 --- src/rime/dict/dictionary.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/rime/dict/dictionary.cc b/src/rime/dict/dictionary.cc index b36189f78..0e8c922a9 100644 --- a/src/rime/dict/dictionary.cc +++ b/src/rime/dict/dictionary.cc @@ -131,11 +131,12 @@ bool DictEntryIterator::FindNextEntry() { if (++chunk.cursor >= chunk.size) { ++chunk_index_; } - else { - // reorder chunks since the current chunk has got a new head element - Sort(); + if (exhausted()) { + return false; } - return !exhausted(); + // reorder chunks to move the one with the best entry to head + Sort(); + return true; } bool DictEntryIterator::Next() {