projects
/
platform
/
upstream
/
libpinyin.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fe5d371
)
re-factor remove_phrase_item.
author
Peng Wu
<alexepico@gmail.com>
Mon, 16 Aug 2010 05:50:50 +0000
(13:50 +0800)
committer
Peng Wu
<alexepico@gmail.com>
Mon, 16 Aug 2010 05:50:50 +0000
(13:50 +0800)
src/storage/phrase_index.cpp
patch
|
blob
|
history
diff --git
a/src/storage/phrase_index.cpp
b/src/storage/phrase_index.cpp
index
188421a
..
f87d834
100644
(file)
--- a/
src/storage/phrase_index.cpp
+++ b/
src/storage/phrase_index.cpp
@@
-154,32
+154,15
@@
bool SubPhraseIndex::add_phrase_item(phrase_token_t token, PhraseItem * item){
}
bool SubPhraseIndex::remove_phrase_item(phrase_token_t token, PhraseItem * & item){
}
bool SubPhraseIndex::remove_phrase_item(phrase_token_t token, PhraseItem * & item){
- table_offset_t offset;
- guint8 phrase_length;
- guint8 n_prons;
-
- bool result = m_phrase_index.get_content
- ((token & PHRASE_MASK)
- * sizeof(table_offset_t), &offset, sizeof(table_offset_t));
-
- if ( !result )
- return result;
-
- if ( 0 == offset )
- return false;
+ PhraseItem old_item;
-
result = m_phrase_content.get_content(offset, &phrase_length, sizeof(guint8)
);
- if (
!result
)
- return result;
+
int result = get_phrase_item(token, old_item
);
+ if (
!result
)
+
return result;
- result = m_phrase_content.get_content(offset+sizeof(guint8), &n_prons, sizeof(guint8));
- if ( !result )
- return result;
-
- size_t length = phrase_item_header + phrase_length * sizeof ( utf16_t ) + n_prons * ( phrase_length * sizeof (PinyinKey) + sizeof(guint32) );
item = new PhraseItem;
//implictly copy data from m_chunk_content.
item = new PhraseItem;
//implictly copy data from m_chunk_content.
- item->m_chunk.set_content(0, (char *)
m_phrase_content.begin() + offset, length
);
+ item->m_chunk.set_content(0, (char *)
old_item.m_chunk.begin() , old_item.m_chunk.size()
);
const table_offset_t zero_const = 0;
m_phrase_index.set_content((token & PHRASE_MASK)
const table_offset_t zero_const = 0;
m_phrase_index.set_content((token & PHRASE_MASK)