mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
am b384cb28
: Merge "Fix children position reading for dynamic patricia trie."
* commit 'b384cb28a14fe97533d5ac96b6fc319da50b1d10': Fix children position reading for dynamic patricia trie.
This commit is contained in:
commit
7c1a6f9787
@ -45,14 +45,10 @@ void DynamicPatriciaTrieNodeReader::fetchNodeInfoFromBufferAndProcessMovedNode(c
|
|||||||
} else {
|
} else {
|
||||||
mProbability = NOT_A_PROBABILITY;
|
mProbability = NOT_A_PROBABILITY;
|
||||||
}
|
}
|
||||||
if (hasChildren()) {
|
mChildrenPos = DynamicPatriciaTrieReadingUtils::readChildrenPositionAndAdvancePosition(
|
||||||
mChildrenPos = DynamicPatriciaTrieReadingUtils::readChildrenPositionAndAdvancePosition(
|
dictBuf, mFlags, &pos);
|
||||||
dictBuf, mFlags, &pos);
|
if (usesAdditionalBuffer && mChildrenPos != NOT_A_DICT_POS) {
|
||||||
if (usesAdditionalBuffer && mChildrenPos != NOT_A_DICT_POS) {
|
mChildrenPos += mOriginalDictSize;
|
||||||
mChildrenPos += mOriginalDictSize;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mChildrenPos = NOT_A_DICT_POS;
|
|
||||||
}
|
}
|
||||||
if (usesAdditionalBuffer) {
|
if (usesAdditionalBuffer) {
|
||||||
pos += mOriginalDictSize;
|
pos += mOriginalDictSize;
|
||||||
|
@ -71,7 +71,7 @@ class DynamicPatriciaTrieNodeReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AK_FORCE_INLINE bool hasChildren() const {
|
AK_FORCE_INLINE bool hasChildren() const {
|
||||||
return PatriciaTrieReadingUtils::hasChildrenInFlags(mFlags);
|
return mChildrenPos != NOT_A_DICT_POS;
|
||||||
}
|
}
|
||||||
|
|
||||||
AK_FORCE_INLINE bool isTerminal() const {
|
AK_FORCE_INLINE bool isTerminal() const {
|
||||||
|
@ -32,7 +32,13 @@ const DptReadingUtils::NodeFlags DptReadingUtils::FLAG_IS_DELETED = 0x80;
|
|||||||
const uint8_t *const buffer, const NodeFlags flags, int *const pos) {
|
const uint8_t *const buffer, const NodeFlags flags, int *const pos) {
|
||||||
if ((flags & MASK_MOVED) == FLAG_IS_NOT_MOVED) {
|
if ((flags & MASK_MOVED) == FLAG_IS_NOT_MOVED) {
|
||||||
const int base = *pos;
|
const int base = *pos;
|
||||||
return base + ByteArrayUtils::readSint24AndAdvancePosition(buffer, pos);
|
const int offset = ByteArrayUtils::readSint24AndAdvancePosition(buffer, pos);
|
||||||
|
if (offset == 0) {
|
||||||
|
// 0 offset means that the node does not have children.
|
||||||
|
return NOT_A_DICT_POS;
|
||||||
|
} else {
|
||||||
|
return base + offset;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return NOT_A_DICT_POS;
|
return NOT_A_DICT_POS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user