Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9fdeda9c authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi Committed by Android Git Automerger
Browse files

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

* commit 'f6b7c3a6':
  Fix parent position reading for ver3 dict.
parents 1c558a31 f6b7c3a6
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -27,7 +27,9 @@ void DynamicPatriciaTrieNodeReader::fetchNodeInfoFromBufferAndProcessMovedNode(c
    const uint8_t *const dictRoot = mBinaryDictionaryInfo->getDictRoot();
    int pos = nodePos;
    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) {
        mCodePointCount = PatriciaTrieReadingUtils::getCharsAndAdvancePosition(
                dictRoot, mFlags, maxCodePointCount, outCodePoints, &pos);
+1 −1
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ int DynamicPatriciaTriePolicy::getCodePointsAndProbabilityAndReturnCodePointCoun
        reverseCodePoints[codePointCount++] = mergedNodeCodePoints[i];
    }
    // 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
        // infinite loop.
        if (nodeReader.isDeleted() || codePointCount > maxCodePointCount
+1 −2
Original line number Diff line number Diff line
@@ -39,8 +39,7 @@ class DynamicPatriciaTrieReadingUtils {

    static AK_FORCE_INLINE int getParentPosAndAdvancePosition(const uint8_t *const buffer,
            int *const pos) {
        const int base = *pos;
        return base + ByteArrayUtils::readSint24AndAdvancePosition(buffer, pos);
        return ByteArrayUtils::readSint24AndAdvancePosition(buffer, pos);
    }

    static int readChildrenPositionAndAdvancePosition(const uint8_t *const buffer,