summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-05-16 14:37:55 +0800
committerPeng Wu <alexepico@gmail.com>2012-05-16 14:37:55 +0800
commitef71c282849298f8c8065bd8d6f8d5a4c385e4db (patch)
treedab93af19da2afe10c7b385b6160e0c7914d24d0
parent6c7f7766ad087234c45f0d4115e59faaf34bcadf (diff)
downloadlibpinyin-ef71c282849298f8c8065bd8d6f8d5a4c385e4db.tar.gz
libpinyin-ef71c282849298f8c8065bd8d6f8d5a4c385e4db.tar.xz
libpinyin-ef71c282849298f8c8065bd8d6f8d5a4c385e4db.zip
update pinyin.cpp
-rw-r--r--src/pinyin.cpp34
1 files changed, 5 insertions, 29 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index 0e3e99b..c028dc0 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -569,12 +569,8 @@ static void _append_items(pinyin_context_t * context,
PhraseIndexRanges ranges,
lookup_candidate_t * template_item,
CandidateVector items) {
- guint8 min_index, max_index;
- assert( ERROR_OK == context->m_phrase_index->
- get_sub_phrase_range(min_index, max_index));
-
/* reduce and append to a single GArray. */
- for (size_t m = min_index; m <= max_index; ++m) {
+ for (size_t m = 0; m <= PHRASE_INDEX_LIBRARY_COUNT; ++m) {
if (NULL == ranges[m])
continue;
@@ -683,14 +679,7 @@ bool pinyin_get_candidates(pinyin_instance_t * instance,
PhraseIndexRanges ranges;
memset(ranges, 0, sizeof(ranges));
-
- guint8 min_index, max_index;
- assert( ERROR_OK == context->m_phrase_index->
- get_sub_phrase_range(min_index, max_index));
-
- for (size_t m = min_index; m <= max_index; ++m) {
- ranges[m] = g_array_new(FALSE, FALSE, sizeof(PhraseIndexRange));
- }
+ context->m_phrase_index->prepare_ranges(ranges);
GArray * items = g_array_new(FALSE, FALSE, sizeof(lookup_candidate_t));
@@ -732,10 +721,7 @@ bool pinyin_get_candidates(pinyin_instance_t * instance,
g_array_free(items, TRUE);
- for (size_t m = min_index; m <= max_index; ++m) {
- if (ranges[m])
- g_array_free(ranges[m], TRUE);
- }
+ context->m_phrase_index->destroy_ranges(ranges);
if (system_gram)
delete system_gram;
@@ -1017,14 +1003,7 @@ bool pinyin_get_full_pinyin_candidates(pinyin_instance_t * instance,
PhraseIndexRanges ranges;
memset(ranges, 0, sizeof(ranges));
-
- guint8 min_index, max_index;
- assert( ERROR_OK == context->m_phrase_index->
- get_sub_phrase_range(min_index, max_index));
-
- for (size_t m = min_index; m <= max_index; ++m) {
- ranges[m] = g_array_new(FALSE, FALSE, sizeof(PhraseIndexRange));
- }
+ context->m_phrase_index->prepare_ranges(ranges);
GArray * items = g_array_new(FALSE, FALSE, sizeof(lookup_candidate_t));
@@ -1111,10 +1090,7 @@ bool pinyin_get_full_pinyin_candidates(pinyin_instance_t * instance,
g_array_free(items, TRUE);
- for (size_t m = min_index; m <= max_index; ++m) {
- if (ranges[m])
- g_array_free(ranges[m], TRUE);
- }
+ context->m_phrase_index->destroy_ranges(ranges);
if (system_gram)
delete system_gram;