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

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

Add node flags creating methods.

Bug: 6669677
Change-Id: Ieb4178da61fa38f6b32baefa099cc0724f9fb6be
parent b690c039
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -56,6 +56,15 @@ class DynamicPatriciaTrieReadingUtils {
        return FLAG_IS_DELETED == (MASK_MOVED & flags);
    }

    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;
        return flags;
    }

 private:
    DISALLOW_IMPLICIT_CONSTRUCTORS(DynamicPatriciaTrieReadingUtils);

+23 −0
Original line number Diff line number Diff line
@@ -119,6 +119,29 @@ class PatriciaTrieReadingUtils {
        return FLAG_CHILDREN_POSITION_TYPE_NOPOSITION != (MASK_CHILDREN_POSITION_TYPE & flags);
    }

    static AK_FORCE_INLINE NodeFlags createAndGetFlags(const bool isBlacklisted,
            const bool isNotAWord, const bool isTerminal, const bool hasShortcutTargets,
            const bool hasBigrams, const bool hasMultipleChars,
            const int childrenPositionFieldSize) {
        NodeFlags nodeFlags = 0;
        nodeFlags = isBlacklisted ? (nodeFlags | FLAG_IS_BLACKLISTED) : nodeFlags;
        nodeFlags = isNotAWord ? (nodeFlags | FLAG_IS_NOT_A_WORD) : nodeFlags;
        nodeFlags = isTerminal ? (nodeFlags | FLAG_IS_TERMINAL) : nodeFlags;
        nodeFlags = hasShortcutTargets ? (nodeFlags | FLAG_HAS_SHORTCUT_TARGETS) : nodeFlags;
        nodeFlags = hasBigrams ? (nodeFlags | FLAG_HAS_BIGRAMS) : nodeFlags;
        nodeFlags = hasMultipleChars ? (nodeFlags | FLAG_HAS_MULTIPLE_CHARS) : nodeFlags;
        if (childrenPositionFieldSize == 1) {
            nodeFlags |= FLAG_CHILDREN_POSITION_TYPE_ONEBYTE;
        } else if (childrenPositionFieldSize == 2) {
            nodeFlags |= FLAG_CHILDREN_POSITION_TYPE_TWOBYTES;
        } else if (childrenPositionFieldSize == 3) {
            nodeFlags |= FLAG_CHILDREN_POSITION_TYPE_THREEBYTES;
        } else {
            nodeFlags |= FLAG_CHILDREN_POSITION_TYPE_NOPOSITION;
        }
        return nodeFlags;
    }

 private:
    DISALLOW_IMPLICIT_CONSTRUCTORS(PatriciaTrieReadingUtils);