polish code
authorPeng Wu <alexepico@gmail.com>
Fri, 20 Apr 2012 06:26:48 +0000 (14:26 +0800)
committerPeng Wu <alexepico@gmail.com>
Fri, 20 Apr 2012 06:29:08 +0000 (14:29 +0800)
src/pinyin.cpp
src/storage/pinyin_parser2.cpp

index 0fd52e9..8d2314e 100644 (file)
@@ -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;
index e9e5347..33c079a 100644 (file)
@@ -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;