Skip to content
Snippets Groups Projects
Commit b384cb28 authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi Committed by Android (Google) Code Review
Browse files

Merge "Fix children position reading for dynamic patricia trie."

parents 6c926a1d 69ebca06
No related branches found
No related tags found
No related merge requests found
......@@ -45,14 +45,10 @@ void DynamicPatriciaTrieNodeReader::fetchNodeInfoFromBufferAndProcessMovedNode(c
} else {
mProbability = NOT_A_PROBABILITY;
}
if (hasChildren()) {
mChildrenPos = DynamicPatriciaTrieReadingUtils::readChildrenPositionAndAdvancePosition(
dictBuf, mFlags, &pos);
if (usesAdditionalBuffer && mChildrenPos != NOT_A_DICT_POS) {
mChildrenPos += mOriginalDictSize;
}
} else {
mChildrenPos = NOT_A_DICT_POS;
mChildrenPos = DynamicPatriciaTrieReadingUtils::readChildrenPositionAndAdvancePosition(
dictBuf, mFlags, &pos);
if (usesAdditionalBuffer && mChildrenPos != NOT_A_DICT_POS) {
mChildrenPos += mOriginalDictSize;
}
if (usesAdditionalBuffer) {
pos += mOriginalDictSize;
......
......@@ -71,7 +71,7 @@ class DynamicPatriciaTrieNodeReader {
}
AK_FORCE_INLINE bool hasChildren() const {
return PatriciaTrieReadingUtils::hasChildrenInFlags(mFlags);
return mChildrenPos != NOT_A_DICT_POS;
}
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) {
if ((flags & MASK_MOVED) == FLAG_IS_NOT_MOVED) {
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 {
return NOT_A_DICT_POS;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment