diff options
author | Elliott Hughes <enh@google.com> | 2014-05-14 01:55:40 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-05-14 01:55:40 +0000 |
commit | d9dc20dbe8fb8a6ccff58e4954e10b93b26d31bf (patch) | |
tree | abe349b27d8fb4f067bb5359fbad7ebae307d1d9 | |
parent | dc4c83e77cfeaf682c13fedbf2fdf901c15b8188 (diff) | |
parent | c76bdf94eab1478bc148b9a38882cb95edaf51e3 (diff) | |
download | PinyinIME-d9dc20dbe8fb8a6ccff58e4954e10b93b26d31bf.tar.gz |
Merge "Using uint32 instead of size_t to parse the Pinyin dictionary"
-rw-r--r-- | jni/include/dictdef.h | 4 | ||||
-rw-r--r-- | jni/include/dictlist.h | 4 | ||||
-rw-r--r-- | jni/share/dictlist.cpp | 6 | ||||
-rw-r--r-- | jni/share/dicttrie.cpp | 21 | ||||
-rw-r--r-- | jni/share/ngram.cpp | 4 | ||||
-rw-r--r-- | jni/share/spellingtrie.cpp | 8 |
6 files changed, 23 insertions, 24 deletions
diff --git a/jni/include/dictdef.h b/jni/include/dictdef.h index 3e79d98..5e1d781 100644 --- a/jni/include/dictdef.h +++ b/jni/include/dictdef.h @@ -109,8 +109,8 @@ typedef struct { * A node occupies 16 bytes. so, totallly less than 16 * 500 = 8K */ struct LmaNodeLE0 { - size_t son_1st_off; - size_t homo_idx_buf_off; + uint32 son_1st_off; + uint32 homo_idx_buf_off; uint16 spl_idx; uint16 num_of_son; uint16 num_of_homo; diff --git a/jni/include/dictlist.h b/jni/include/dictlist.h index 5fcc12f..b0eb2d0 100644 --- a/jni/include/dictlist.h +++ b/jni/include/dictlist.h @@ -42,9 +42,9 @@ class DictList { // Starting position of those words whose lengths are i+1, counted in // char16 - size_t start_pos_[kMaxLemmaSize + 1]; + uint32 start_pos_[kMaxLemmaSize + 1]; - size_t start_id_[kMaxLemmaSize + 1]; + uint32 start_id_[kMaxLemmaSize + 1]; int (*cmp_func_[kMaxLemmaSize])(const void *, const void *); diff --git a/jni/share/dictlist.cpp b/jni/share/dictlist.cpp index aa7905c..b6becf1 100644 --- a/jni/share/dictlist.cpp +++ b/jni/share/dictlist.cpp @@ -414,14 +414,14 @@ bool DictList::load_list(FILE *fp) { initialized_ = false; - if (fread(&scis_num_, sizeof(size_t), 1, fp) != 1) + if (fread(&scis_num_, sizeof(uint32), 1, fp) != 1) return false; - if (fread(start_pos_, sizeof(size_t), kMaxLemmaSize + 1, fp) != + if (fread(start_pos_, sizeof(uint32), kMaxLemmaSize + 1, fp) != kMaxLemmaSize + 1) return false; - if (fread(start_id_, sizeof(size_t), kMaxLemmaSize + 1, fp) != + if (fread(start_id_, sizeof(uint32), kMaxLemmaSize + 1, fp) != kMaxLemmaSize + 1) return false; diff --git a/jni/share/dicttrie.cpp b/jni/share/dicttrie.cpp index 88b819d..6255f83 100644 --- a/jni/share/dicttrie.cpp +++ b/jni/share/dicttrie.cpp @@ -113,16 +113,16 @@ bool DictTrie::save_dict(FILE *fp) { if (NULL == fp) return false; - if (fwrite(&lma_node_num_le0_, sizeof(size_t), 1, fp) != 1) + if (fwrite(&lma_node_num_le0_, sizeof(uint32), 1, fp) != 1) return false; - if (fwrite(&lma_node_num_ge1_, sizeof(size_t), 1, fp) != 1) + if (fwrite(&lma_node_num_ge1_, sizeof(uint32), 1, fp) != 1) return false; - if (fwrite(&lma_idx_buf_len_, sizeof(size_t), 1, fp) != 1) + if (fwrite(&lma_idx_buf_len_, sizeof(uint32), 1, fp) != 1) return false; - if (fwrite(&top_lmas_num_, sizeof(size_t), 1, fp) != 1) + if (fwrite(&top_lmas_num_, sizeof(uint32), 1, fp) != 1) return false; if (fwrite(root_, sizeof(LmaNodeLE0), lma_node_num_le0_, fp) @@ -168,19 +168,18 @@ bool DictTrie::save_dict(const char *filename) { bool DictTrie::load_dict(FILE *fp) { if (NULL == fp) return false; - - if (fread(&lma_node_num_le0_, sizeof(size_t), 1, fp) != 1) + if (fread(&lma_node_num_le0_, sizeof(uint32), 1, fp) != 1) return false; - if (fread(&lma_node_num_ge1_, sizeof(size_t), 1, fp) != 1) + if (fread(&lma_node_num_ge1_, sizeof(uint32), 1, fp) != 1) return false; - if (fread(&lma_idx_buf_len_, sizeof(size_t), 1, fp) != 1) + if (fread(&lma_idx_buf_len_, sizeof(uint32), 1, fp) != 1) return false; - if (fread(&top_lmas_num_, sizeof(size_t), 1, fp) != 1 || - top_lmas_num_ >= lma_idx_buf_len_) - return false; + if (fread(&top_lmas_num_, sizeof(uint32), 1, fp) != 1 || + top_lmas_num_ >= lma_idx_buf_len_) + return false; free_resource(false); diff --git a/jni/share/ngram.cpp b/jni/share/ngram.cpp index 104b853..6aec850 100644 --- a/jni/share/ngram.cpp +++ b/jni/share/ngram.cpp @@ -164,7 +164,7 @@ bool NGram::save_ngram(FILE *fp) { if (0 == idx_num_ || NULL == freq_codes_ || NULL == lma_freq_idx_) return false; - if (fwrite(&idx_num_, sizeof(size_t), 1, fp) != 1) + if (fwrite(&idx_num_, sizeof(uint32), 1, fp) != 1) return false; if (fwrite(freq_codes_, sizeof(LmaScoreType), kCodeBookSize, fp) != @@ -183,7 +183,7 @@ bool NGram::load_ngram(FILE *fp) { initialized_ = false; - if (fread(&idx_num_, sizeof(size_t), 1, fp) != 1 ) + if (fread(&idx_num_, sizeof(uint32), 1, fp) != 1 ) return false; if (NULL != lma_freq_idx_) diff --git a/jni/share/spellingtrie.cpp b/jni/share/spellingtrie.cpp index 85be46b..57fa1f0 100644 --- a/jni/share/spellingtrie.cpp +++ b/jni/share/spellingtrie.cpp @@ -640,10 +640,10 @@ bool SpellingTrie::save_spl_trie(FILE *fp) { if (NULL == fp || NULL == spelling_buf_) return false; - if (fwrite(&spelling_size_, sizeof(size_t), 1, fp) != 1) + if (fwrite(&spelling_size_, sizeof(uint32), 1, fp) != 1) return false; - if (fwrite(&spelling_num_, sizeof(size_t), 1, fp) != 1) + if (fwrite(&spelling_num_, sizeof(uint32), 1, fp) != 1) return false; if (fwrite(&score_amplifier_, sizeof(float), 1, fp) != 1) @@ -663,10 +663,10 @@ bool SpellingTrie::load_spl_trie(FILE *fp) { if (NULL == fp) return false; - if (fread(&spelling_size_, sizeof(size_t), 1, fp) != 1) + if (fread(&spelling_size_, sizeof(uint32), 1, fp) != 1) return false; - if (fread(&spelling_num_, sizeof(size_t), 1, fp) != 1) + if (fread(&spelling_num_, sizeof(uint32), 1, fp) != 1) return false; if (fread(&score_amplifier_, sizeof(float), 1, fp) != 1) |