am f6b7c3a6: Merge "Fix parent position reading for ver3 dict."

* commit 'f6b7c3a62f9d46a871e13a8e8818fb05f7fc0eb6':
  Fix parent position reading for ver3 dict.
This commit is contained in:
Keisuke Kuroyanagi 2013-08-08 00:36:44 -07:00 committed by Android Git Automerger
commit 9fdeda9c9a
3 changed files with 5 additions and 4 deletions

View file

@ -27,7 +27,9 @@ void DynamicPatriciaTrieNodeReader::fetchNodeInfoFromBufferAndProcessMovedNode(c
const uint8_t *const dictRoot = mBinaryDictionaryInfo->getDictRoot(); const uint8_t *const dictRoot = mBinaryDictionaryInfo->getDictRoot();
int pos = nodePos; int pos = nodePos;
mFlags = PatriciaTrieReadingUtils::getFlagsAndAdvancePosition(dictRoot, &pos); mFlags = PatriciaTrieReadingUtils::getFlagsAndAdvancePosition(dictRoot, &pos);
mParentPos = DynamicPatriciaTrieReadingUtils::getParentPosAndAdvancePosition(dictRoot, &pos); const int parentPos =
DynamicPatriciaTrieReadingUtils::getParentPosAndAdvancePosition(dictRoot, &pos);
mParentPos = (parentPos != 0) ? mNodePos + parentPos : NOT_A_DICT_POS;
if (outCodePoints != 0) { if (outCodePoints != 0) {
mCodePointCount = PatriciaTrieReadingUtils::getCharsAndAdvancePosition( mCodePointCount = PatriciaTrieReadingUtils::getCharsAndAdvancePosition(
dictRoot, mFlags, maxCodePointCount, outCodePoints, &pos); dictRoot, mFlags, maxCodePointCount, outCodePoints, &pos);

View file

@ -94,7 +94,7 @@ int DynamicPatriciaTriePolicy::getCodePointsAndProbabilityAndReturnCodePointCoun
reverseCodePoints[codePointCount++] = mergedNodeCodePoints[i]; reverseCodePoints[codePointCount++] = mergedNodeCodePoints[i];
} }
// Then, follow parent pos toward the root node. // Then, follow parent pos toward the root node.
while (nodeReader.getParentPos() != getRootPosition()) { while (nodeReader.getParentPos() != NOT_A_DICT_POS) {
// codePointCount must be incremented at least once in each iteration to ensure preventing // codePointCount must be incremented at least once in each iteration to ensure preventing
// infinite loop. // infinite loop.
if (nodeReader.isDeleted() || codePointCount > maxCodePointCount if (nodeReader.isDeleted() || codePointCount > maxCodePointCount

View file

@ -39,8 +39,7 @@ class DynamicPatriciaTrieReadingUtils {
static AK_FORCE_INLINE int getParentPosAndAdvancePosition(const uint8_t *const buffer, static AK_FORCE_INLINE int getParentPosAndAdvancePosition(const uint8_t *const buffer,
int *const pos) { int *const pos) {
const int base = *pos; return ByteArrayUtils::readSint24AndAdvancePosition(buffer, pos);
return base + ByteArrayUtils::readSint24AndAdvancePosition(buffer, pos);
} }
static int readChildrenPositionAndAdvancePosition(const uint8_t *const buffer, static int readChildrenPositionAndAdvancePosition(const uint8_t *const buffer,