aboutsummaryrefslogtreecommitdiffstats
path: root/native/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-01-15 23:28:07 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2012-01-15 23:28:07 -0800
commit06f2692c78e3bda877143885180f8f9ddc541fee (patch)
tree7e5cfeda545a79d79cb7eb374cbd87ec9a9e9812 /native/src
parent44cf7a12f685eec11232f2dd076e5ea83ee539e4 (diff)
parentfe9dca7ec3814956e6e545c383106156f568d047 (diff)
downloadlatinime-06f2692c78e3bda877143885180f8f9ddc541fee.tar.gz
latinime-06f2692c78e3bda877143885180f8f9ddc541fee.tar.xz
latinime-06f2692c78e3bda877143885180f8f9ddc541fee.zip
am fe9dca7e: Merge "Read multi-byte char group counts"
* commit 'fe9dca7ec3814956e6e545c383106156f568d047': Read multi-byte char group counts
Diffstat (limited to 'native/src')
-rw-r--r--native/src/binary_format.h4
-rw-r--r--native/src/unigram_dictionary.cpp5
2 files changed, 6 insertions, 3 deletions
diff --git a/native/src/binary_format.h b/native/src/binary_format.h
index 9944fa2bd..1d74998f6 100644
--- a/native/src/binary_format.h
+++ b/native/src/binary_format.h
@@ -61,7 +61,9 @@ inline int BinaryFormat::detectFormat(const uint8_t* const dict) {
}
inline int BinaryFormat::getGroupCountAndForwardPointer(const uint8_t* const dict, int* pos) {
- return dict[(*pos)++];
+ const int msb = dict[(*pos)++];
+ if (msb < 0x80) return msb;
+ return ((msb & 0x7F) << 8) | dict[(*pos)++];
}
inline uint8_t BinaryFormat::getFlagsAndForwardPointer(const uint8_t* const dict, int* pos) {
diff --git a/native/src/unigram_dictionary.cpp b/native/src/unigram_dictionary.cpp
index cd73fe3f8..ca7f0be0c 100644
--- a/native/src/unigram_dictionary.cpp
+++ b/native/src/unigram_dictionary.cpp
@@ -507,9 +507,10 @@ int UnigramDictionary::getMostFrequentWordLikeInner(const uint16_t * const inWor
int maxFreq = -1;
const uint8_t* const root = DICT_ROOT;
- mStackChildCount[0] = root[0];
+ int startPos = 0;
+ mStackChildCount[0] = BinaryFormat::getGroupCountAndForwardPointer(root, &startPos);
mStackInputIndex[0] = 0;
- mStackSiblingPos[0] = 1;
+ mStackSiblingPos[0] = startPos;
while (depth >= 0) {
const int charGroupCount = mStackChildCount[depth];
int pos = mStackSiblingPos[depth];