summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-04-19 14:51:00 +0800
committerPeng Wu <alexepico@gmail.com>2012-04-19 14:51:00 +0800
commitbe2be435b1ad0371603407c567475d1490ade1ed (patch)
tree1b017623f600ab87363a384e4fb3dc0d1466857b
parentfe4688fd9725b295a31c3475c0a117c78de59a0c (diff)
downloadlibpinyin-be2be435b1ad0371603407c567475d1490ade1ed.tar.gz
libpinyin-be2be435b1ad0371603407c567475d1490ade1ed.tar.xz
libpinyin-be2be435b1ad0371603407c567475d1490ade1ed.zip
refine retrieve_divided_item
-rw-r--r--src/pinyin.cpp7
-rw-r--r--src/storage/pinyin_parser2.cpp11
-rw-r--r--src/storage/pinyin_parser2.h3
3 files changed, 7 insertions, 14 deletions
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();