From: Peng Wu Date: Thu, 19 Apr 2012 06:51:00 +0000 (+0800) Subject: refine retrieve_divided_item X-Git-Tag: 0.6.91~46 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=be2be435b1ad0371603407c567475d1490ade1ed;p=platform%2Fupstream%2Flibpinyin.git refine retrieve_divided_item --- diff --git a/src/pinyin.cpp b/src/pinyin.cpp index 7318d44..0fd52e9 100644 --- a/src/pinyin.cpp +++ b/src/pinyin.cpp @@ -731,6 +731,10 @@ static bool _try_divided_table(pinyin_instance_t * instance, ChewingKeyVector & pinyin_keys = instance->m_pinyin_keys; ChewingKeyRestVector & pinyin_key_rests = instance->m_pinyin_key_rests; + assert(pinyin_keys->len == pinyin_key_rests->len); + gint num_keys = pinyin_keys->len; + assert(offset < num_keys); + /* handle "^xian$" -> "xi'an" here */ ChewingKey * key = &g_array_index(pinyin_keys, ChewingKey, offset); ChewingKeyRest * rest = &g_array_index(pinyin_key_rests, @@ -750,8 +754,7 @@ static bool _try_divided_table(pinyin_instance_t * instance, } item = context->m_full_pinyin_parser->retrieve_divided_item - (options, offset, pinyin_keys, pinyin_key_rests, - instance->m_raw_full_pinyin, + (options, key, rest, instance->m_raw_full_pinyin, strlen(instance->m_raw_full_pinyin)); if (item) { diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index b4175b1..e9e5347 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -574,17 +574,8 @@ bool FullPinyinParser2::post_process2(pinyin_option_t options, } const divided_table_item_t * FullPinyinParser2::retrieve_divided_item -(pinyin_option_t options, size_t offset, - ChewingKeyVector & keys, ChewingKeyRestVector & key_rests, +(pinyin_option_t options, ChewingKey * key, ChewingKeyRest * rest, const char * str, int len) const { - assert(keys->len == key_rests->len); - - gint num_keys = keys->len; - assert(offset < num_keys); - - ChewingKey * key = &g_array_index(keys, ChewingKey, offset); - ChewingKeyRest * rest = &g_array_index(key_rests, - ChewingKeyRest, offset); guint16 tone = CHEWING_ZERO_TONE; /* lookup divided table */ diff --git a/src/storage/pinyin_parser2.h b/src/storage/pinyin_parser2.h index 77ed3d4..50bcef0 100644 --- a/src/storage/pinyin_parser2.h +++ b/src/storage/pinyin_parser2.h @@ -153,8 +153,7 @@ protected: public: const divided_table_item_t * retrieve_divided_item - (pinyin_option_t options, size_t offset, - ChewingKeyVector & keys, ChewingKeyRestVector & key_rests, + (pinyin_option_t options, ChewingKey * key, ChewingKeyRest * rest, const char * str, int len) const; public: FullPinyinParser2();