diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/memory_chunk.h | 2 | ||||
-rw-r--r-- | src/storage/phrase_index.h | 4 | ||||
-rw-r--r-- | src/storage/phrase_index_logger.h | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/include/memory_chunk.h b/src/include/memory_chunk.h index 6fd9d9a..3d9ea35 100644 --- a/src/include/memory_chunk.h +++ b/src/include/memory_chunk.h @@ -119,7 +119,7 @@ public: return m_data_end; } - size_t size(){ + size_t size() const{ return m_data_end - m_data_begin; } diff --git a/src/storage/phrase_index.h b/src/storage/phrase_index.h index 17d81c4..e1d4de6 100644 --- a/src/storage/phrase_index.h +++ b/src/storage/phrase_index.h @@ -137,14 +137,14 @@ public: void append_pronunciation(PinyinKey * pinyin, guint32 freq); void remove_nth_pronunciation(size_t index); - bool operator == (PhraseItem & rhs){ + bool operator == (const PhraseItem & rhs) const{ if (m_chunk.size() != rhs.m_chunk.size()) return false; return memcmp(m_chunk.begin(), rhs.m_chunk.begin(), m_chunk.size()) == 0; } - bool operator != (PhraseItem & rhs){ + bool operator != (const PhraseItem & rhs) const{ return ! (*this == rhs); } }; diff --git a/src/storage/phrase_index_logger.h b/src/storage/phrase_index_logger.h index 95f8e8b..c74169d 100644 --- a/src/storage/phrase_index_logger.h +++ b/src/storage/phrase_index_logger.h @@ -98,9 +98,10 @@ public: m_chunk->get_content(offset, &token, sizeof(phrase_token_t)); offset += sizeof(phrase_token_t); + oldone->set_size(0); newone->set_size(0); + switch(log_type){ case LOG_ADD_RECORD:{ - oldone->set_size(0); size_t len = 0; m_chunk->get_content(offset, &len, sizeof(size_t)); offset += sizeof(size_t); @@ -109,7 +110,6 @@ public: break; } case LOG_REMOVE_RECORD:{ - newone->set_size(0); size_t len = 0; m_chunk->get_content(offset, &len, sizeof(size_t)); offset += sizeof(size_t); |