summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-08-22 19:12:53 +0800
committerPeng Wu <alexepico@gmail.com>2011-08-22 19:12:53 +0800
commitcda6da120aff1d3e228a9e99f0435ce862e05e12 (patch)
treeaeeaaac6196ae8be09792178b21cad1cf5ae4982 /src
parent806ee677ed908de317f0bbf377279d2083dce731 (diff)
downloadlibpinyin-cda6da120aff1d3e228a9e99f0435ce862e05e12.tar.gz
libpinyin-cda6da120aff1d3e228a9e99f0435ce862e05e12.tar.xz
libpinyin-cda6da120aff1d3e228a9e99f0435ce862e05e12.zip
fixes phrase index logger
Diffstat (limited to 'src')
-rw-r--r--src/include/memory_chunk.h2
-rw-r--r--src/storage/phrase_index.h4
-rw-r--r--src/storage/phrase_index_logger.h4
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);