From cf8f34957cb56513848ed6f24320c8c3136b6053 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Fri, 18 Apr 2014 14:48:35 +0800 Subject: update BuiltinSymbolSection::fillLookupTableByPage --- src/ZYZBuiltinSymbolSection.cc | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/ZYZBuiltinSymbolSection.cc') diff --git a/src/ZYZBuiltinSymbolSection.cc b/src/ZYZBuiltinSymbolSection.cc index 7053e00..5576187 100644 --- a/src/ZYZBuiltinSymbolSection.cc +++ b/src/ZYZBuiltinSymbolSection.cc @@ -56,16 +56,28 @@ BuiltinSymbolSection::initCandidates (const String & lookup) bool BuiltinSymbolSection::fillLookupTableByPage () { - /* clear lookup table. */ LookupTable & lookup_table = getLookupTable (); - lookup_table.clear (); - iterator_t iter = m_candidates.begin (); - for (; iter != m_candidates.end (); ++iter) { - lookup_table.appendCandidate (Text (*iter)); + guint len = m_candidates.size (); + + guint filled_nr = lookup_table.size (); + guint page_size = lookup_table.pageSize (); + + /* fill lookup table by libzhuyin get candidates. */ + guint need_nr = MIN (page_size, len - filled_nr); + g_assert (need_nr >=0); + if (need_nr == 0) + return FALSE; + + for (guint i = filled_nr; i < filled_nr + need_nr; i++) { + if (i >= len) /* no more candidates */ + break; + + Text text (m_candidates[i]); + lookup_table.appendCandidate (text); } - return true; + return TRUE; } int -- cgit