summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-09-04 11:17:04 +0800
committerPeng Wu <alexepico@gmail.com>2012-09-04 11:21:45 +0800
commite5cd53d3416a500480db25c2363eabf6877ec67a (patch)
treea98c4e49242a612648669ce7904abe59d1350a78 /tests
parent8a490408bfc367325c32c7d0ad9491de2c96c46d (diff)
downloadlibpinyin-e5cd53d3416a500480db25c2363eabf6877ec67a.tar.gz
libpinyin-e5cd53d3416a500480db25c2363eabf6877ec67a.tar.xz
libpinyin-e5cd53d3416a500480db25c2363eabf6877ec67a.zip
refactor code
Diffstat (limited to 'tests')
-rw-r--r--tests/storage/test_chewing_table.cpp9
-rw-r--r--tests/storage/test_phrase_table.cpp8
2 files changed, 4 insertions, 13 deletions
diff --git a/tests/storage/test_chewing_table.cpp b/tests/storage/test_chewing_table.cpp
index e1189b5..b65b20f 100644
--- a/tests/storage/test_chewing_table.cpp
+++ b/tests/storage/test_chewing_table.cpp
@@ -62,17 +62,12 @@ int main(int argc, char * argv[]) {
phrase_index.prepare_ranges(ranges);
for (size_t i = 0; i < bench_times; ++i) {
+ phrase_index.clear_ranges(ranges);
largetable.search(keys->len, (ChewingKey *)keys->data, ranges);
-
- /* clear ranges. */
- for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
- if (ranges[i])
- g_array_set_size(ranges[i], 0);
- }
}
-
print_time(start, bench_times);
+ phrase_index.clear_ranges(ranges);
largetable.search(keys->len, (ChewingKey *)keys->data, ranges);
for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
diff --git a/tests/storage/test_phrase_table.cpp b/tests/storage/test_phrase_table.cpp
index 968a9f8..706d6bf 100644
--- a/tests/storage/test_phrase_table.cpp
+++ b/tests/storage/test_phrase_table.cpp
@@ -33,16 +33,12 @@ int main(int argc, char * argv[]){
guint32 start = record_time();
for ( size_t i = 0; i < bench_times; ++i){
+ phrase_index.clear_tokens(tokens);
largetable.search(phrase_len, new_phrase, tokens);
-
- /* clear tokens. */
- for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
- if (tokens[i])
- g_array_set_size(tokens[i], 0);
- }
}
print_time(start, bench_times);
+ phrase_index.clear_tokens(tokens);
int retval = largetable.search(phrase_len, new_phrase, tokens);
int num = get_first_token(tokens, token);