From 93c159120335d171c4d3a01fcc9f39cf2aeb7205 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Fri, 20 Apr 2012 14:26:48 +0800 Subject: polish code --- src/pinyin.cpp | 11 +++++++---- src/storage/pinyin_parser2.cpp | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pinyin.cpp b/src/pinyin.cpp index 0fd52e9..8d2314e 100644 --- a/src/pinyin.cpp +++ b/src/pinyin.cpp @@ -494,7 +494,7 @@ bool pinyin_in_chewing_keyboard(pinyin_instance_t * instance, static gint compare_item_with_token(gconstpointer lhs, - gconstpointer rhs) { + gconstpointer rhs) { lookup_candidate_t * item_lhs = (lookup_candidate_t *)lhs; lookup_candidate_t * item_rhs = (lookup_candidate_t *)rhs; @@ -505,7 +505,7 @@ static gint compare_item_with_token(gconstpointer lhs, } static gint compare_item_with_frequency(gconstpointer lhs, - gconstpointer rhs) { + gconstpointer rhs) { lookup_candidate_t * item_lhs = (lookup_candidate_t *)lhs; lookup_candidate_t * item_rhs = (lookup_candidate_t *)rhs; @@ -886,12 +886,13 @@ bool pinyin_get_full_pinyin_candidates(pinyin_instance_t * instance, } for (i = pinyin_len; i >= 1; --i) { + bool found = false; g_array_set_size(items, 0); if (2 == i) { /* handle fuzzy pinyin segment here. */ if (options & USE_DIVIDED_TABLE) { - _try_divided_table(instance, ranges, offset, items); + found = _try_divided_table(instance, ranges, offset, items); } if (options & USE_RESPLIT_TABLE) { assert(FALSE); @@ -905,7 +906,9 @@ bool pinyin_get_full_pinyin_candidates(pinyin_instance_t * instance, int retval = context->m_pinyin_table->search (i, keys, ranges); - if ( !(retval & SEARCH_OK) ) + found = (retval & SEARCH_OK) || found; + + if ( !found ) continue; lookup_candidate_t template_item; diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index e9e5347..33c079a 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -576,7 +576,6 @@ bool FullPinyinParser2::post_process2(pinyin_option_t options, const divided_table_item_t * FullPinyinParser2::retrieve_divided_item (pinyin_option_t options, ChewingKey * key, ChewingKeyRest * rest, const char * str, int len) const { - guint16 tone = CHEWING_ZERO_TONE; /* lookup divided table */ size_t k; -- cgit