summaryrefslogtreecommitdiffstats
path: root/src/storage/chewing_large_table.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-11-06 11:12:19 +0800
committerPeng Wu <alexepico@gmail.com>2012-11-06 11:20:32 +0800
commit92f204109d210d3670986fee625d9d708fb53a2d (patch)
treee2402bc0e3f89fda6ab00ca09544eb78f26169f5 /src/storage/chewing_large_table.cpp
parented47add4965f5a22f697e1ec795be9e03065b18a (diff)
downloadlibpinyin-92f204109d210d3670986fee625d9d708fb53a2d.tar.gz
libpinyin-92f204109d210d3670986fee625d9d708fb53a2d.tar.xz
libpinyin-92f204109d210d3670986fee625d9d708fb53a2d.zip
re-factor remove index in progress
Diffstat (limited to 'src/storage/chewing_large_table.cpp')
-rw-r--r--src/storage/chewing_large_table.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/storage/chewing_large_table.cpp b/src/storage/chewing_large_table.cpp
index 68eb3ed..7779aae 100644
--- a/src/storage/chewing_large_table.cpp
+++ b/src/storage/chewing_large_table.cpp
@@ -488,9 +488,18 @@ int ChewingBitmapIndexLevel::remove_index(int phrase_length,
[first_key.m_initial][first_key.m_middle]
[first_key.m_final][first_key.m_tone];
- if (length_array)
- return length_array->remove_index(phrase_length - 1, keys + 1, token);
- return ERROR_REMOVE_ITEM_DONOT_EXISTS;
+ if (NULL == length_array)
+ return ERROR_REMOVE_ITEM_DONOT_EXISTS;
+
+ int retval = length_array->remove_index(phrase_length - 1, keys + 1, token);
+
+ /* remove empty array. */
+ if (0 == length_array->get_length()) {
+ delete length_array;
+ length_array = NULL;
+ }
+
+ return retval;
}
int ChewingLengthIndexLevel::add_index(int phrase_length,