summaryrefslogtreecommitdiffstats
path: root/src/storage
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-03-09 11:48:20 +0800
committerPeng Wu <alexepico@gmail.com>2016-03-09 11:48:20 +0800
commit270402c3e14b0a975da5e80e456befebdd85eced (patch)
treea0b07bf1b74acb68fb7fa58ba114ba62ecdd5815 /src/storage
parent026f53bd34ba93050178b36fc4bdde2a7528b5cc (diff)
add const modifiers
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/chewing_large_table2.h12
-rw-r--r--src/storage/chewing_large_table2_bdb.cpp12
-rw-r--r--src/storage/chewing_large_table2_bdb.h2
3 files changed, 13 insertions, 13 deletions
diff --git a/src/storage/chewing_large_table2.h b/src/storage/chewing_large_table2.h
index f612718..62d8e38 100644
--- a/src/storage/chewing_large_table2.h
+++ b/src/storage/chewing_large_table2.h
@@ -48,9 +48,6 @@ protected:
protected:
MemoryChunk m_chunk;
- /* The cache item of IndexItem. */
- IndexItem m_cache_item;
-
private:
/* Disallow used outside. */
ChewingTableEntry() {}
@@ -60,7 +57,7 @@ public:
/* compress consecutive tokens */
int convert(const ChewingKey keys[],
const IndexItem * begin, const IndexItem * end,
- PhraseIndexRanges ranges) {
+ PhraseIndexRanges ranges) const {
const IndexItem * iter = NULL;
PhraseIndexRange cursor;
GArray * head, * cursor_head = NULL;
@@ -104,14 +101,15 @@ public:
/* search method */
int search(/* in */ const ChewingKey keys[],
- /* out */ PhraseIndexRanges ranges) {
- compute_chewing_index(keys, m_cache_item.m_keys, phrase_length);
+ /* out */ PhraseIndexRanges ranges) const {
+ IndexItem item;
+ compute_chewing_index(keys, item.m_keys, phrase_length);
const IndexItem * begin = (IndexItem *) m_chunk.begin();
const IndexItem * end = (IndexItem *) m_chunk.end();
std_lite::pair<const IndexItem *, const IndexItem *> range =
- std_lite::equal_range(begin, end, m_cache_item,
+ std_lite::equal_range(begin, end, item,
phrase_less_than_with_tones<phrase_length>);
return convert(keys, range.first, range.second, ranges);
diff --git a/src/storage/chewing_large_table2_bdb.cpp b/src/storage/chewing_large_table2_bdb.cpp
index 877af40..ca4c3fa 100644
--- a/src/storage/chewing_large_table2_bdb.cpp
+++ b/src/storage/chewing_large_table2_bdb.cpp
@@ -287,13 +287,15 @@ int ChewingLargeTable2::search_internal(int phrase_length,
/* search method */
int ChewingLargeTable2::search(int phrase_length,
/* in */ const ChewingKey keys[],
- /* out */ PhraseIndexRanges ranges) {
+ /* out */ PhraseIndexRanges ranges) const {
+ ChewingKey index[MAX_PHRASE_LENGTH];
+
if (contains_incomplete_pinyin(keys, phrase_length)) {
- compute_incomplete_chewing_index(keys, m_cache_index, phrase_length);
- return search_internal(phrase_length, m_cache_index, ranges);
+ compute_incomplete_chewing_index(keys, index, phrase_length);
+ return search_internal(phrase_length, index, ranges);
} else {
- compute_chewing_index(keys, m_cache_index, phrase_length);
- return search_internal(phrase_length, m_cache_index, ranges);
+ compute_chewing_index(keys, index, phrase_length);
+ return search_internal(phrase_length, index, ranges);
}
return SEARCH_NONE;
diff --git a/src/storage/chewing_large_table2_bdb.h b/src/storage/chewing_large_table2_bdb.h
index 494d65a..576bee8 100644
--- a/src/storage/chewing_large_table2_bdb.h
+++ b/src/storage/chewing_large_table2_bdb.h
@@ -76,7 +76,7 @@ public:
/* search method */
int search(int phrase_length, /* in */ const ChewingKey keys[],
- /* out */ PhraseIndexRanges ranges);
+ /* out */ PhraseIndexRanges ranges) const;
/* add/remove index method */
int add_index(int phrase_length, /* in */ const ChewingKey keys[],