Add node flags creating methods.
Bug: 6669677 Change-Id: Ieb4178da61fa38f6b32baefa099cc0724f9fb6bemain
parent
b690c03927
commit
e4dcebe0c3
|
@ -56,6 +56,15 @@ class DynamicPatriciaTrieReadingUtils {
|
||||||
return FLAG_IS_DELETED == (MASK_MOVED & flags);
|
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:
|
private:
|
||||||
DISALLOW_IMPLICIT_CONSTRUCTORS(DynamicPatriciaTrieReadingUtils);
|
DISALLOW_IMPLICIT_CONSTRUCTORS(DynamicPatriciaTrieReadingUtils);
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,29 @@ class PatriciaTrieReadingUtils {
|
||||||
return FLAG_CHILDREN_POSITION_TYPE_NOPOSITION != (MASK_CHILDREN_POSITION_TYPE & flags);
|
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:
|
private:
|
||||||
DISALLOW_IMPLICIT_CONSTRUCTORS(PatriciaTrieReadingUtils);
|
DISALLOW_IMPLICIT_CONSTRUCTORS(PatriciaTrieReadingUtils);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue