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

Commit f38969f3 authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi
Browse files

Fix bug of dictionary dynamic updating methods.

Bug: 6669677
Change-Id: I5483adb03e1ac0c27bbfd99d5f4d7cc29809d70a
parent b8e857f7
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -59,9 +59,9 @@ class DynamicPatriciaTrieReadingUtils {
    static AK_FORCE_INLINE NodeFlags updateAndGetFlags(const NodeFlags originalFlags,
            const bool isMoved, const bool isDeleted) {
        NodeFlags flags = originalFlags;
        flags = isMoved ? ((flags & (!MASK_MOVED)) | FLAG_IS_MOVED) : flags;
        flags = isDeleted ? ((flags & (!MASK_MOVED)) | FLAG_IS_DELETED) : flags;
        flags = (!isMoved && !isDeleted) ? ((flags & (!MASK_MOVED)) | FLAG_IS_NOT_MOVED) : flags;
        flags = isMoved ? ((flags & (~MASK_MOVED)) | FLAG_IS_MOVED) : flags;
        flags = isDeleted ? ((flags & (~MASK_MOVED)) | FLAG_IS_DELETED) : flags;
        flags = (!isMoved && !isDeleted) ? ((flags & (~MASK_MOVED)) | FLAG_IS_NOT_MOVED) : flags;
        return flags;
    }

+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ namespace latinime {
bool DynamicPatriciaTrieWritingHelper::addUnigramWord(
        DynamicPatriciaTrieReadingHelper *const readingHelper,
        const int *const wordCodePoints, const int codePointCount, const int probability) {
    int parentPos = NOT_A_VALID_WORD_POS;
    int parentPos = NOT_A_DICT_POS;
    while (!readingHelper->isEnd()) {
        const int matchedCodePointCount = readingHelper->getPrevTotalCodePointCount();
        if (!readingHelper->isMatchedCodePoint(0 /* index */,
+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ bool BufferWithExtendableBuffer::checkAndPrepareWriting(const int pos, const int
                }
            }
            mUsedAdditionalBufferSize += size;
        } else if (pos + size >= tailPosition) {
        } else if (pos + size > tailPosition) {
            // The access will beyond the tail of used region.
            return false;
        }