mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
am ebe3b3e8
: Merge "Fix bug related to dynamic patricia trie bigram adding."
* commit 'ebe3b3e8fd7b7a6ecbffa7088a36c60bfef8807a': Fix bug related to dynamic patricia trie bigram adding.
This commit is contained in:
commit
6af8936bec
@ -58,7 +58,7 @@ void DynamicPatriciaTrieNodeReader::fetchNodeInfoFromBufferAndProcessMovedNode(c
|
||||
mChildrenPosFieldPos += mBuffer->getOriginalBufferSize();
|
||||
}
|
||||
mChildrenPos = DynamicPatriciaTrieReadingUtils::readChildrenPositionAndAdvancePosition(
|
||||
dictBuf, mFlags, &pos);
|
||||
dictBuf, &pos);
|
||||
if (usesAdditionalBuffer && mChildrenPos != NOT_A_DICT_POS) {
|
||||
mChildrenPos += mBuffer->getOriginalBufferSize();
|
||||
}
|
||||
|
@ -29,18 +29,14 @@ const DptReadingUtils::NodeFlags DptReadingUtils::FLAG_IS_MOVED = 0x40;
|
||||
const DptReadingUtils::NodeFlags DptReadingUtils::FLAG_IS_DELETED = 0x80;
|
||||
|
||||
/* static */ int DptReadingUtils::readChildrenPositionAndAdvancePosition(
|
||||
const uint8_t *const buffer, const NodeFlags flags, int *const pos) {
|
||||
if ((flags & MASK_MOVED) == FLAG_IS_NOT_MOVED) {
|
||||
const int base = *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 {
|
||||
const uint8_t *const buffer, int *const pos) {
|
||||
const int base = *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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,8 +42,7 @@ class DynamicPatriciaTrieReadingUtils {
|
||||
return ByteArrayUtils::readSint24AndAdvancePosition(buffer, pos);
|
||||
}
|
||||
|
||||
static int readChildrenPositionAndAdvancePosition(const uint8_t *const buffer,
|
||||
const NodeFlags flags, int *const pos);
|
||||
static int readChildrenPositionAndAdvancePosition(const uint8_t *const buffer, int *const pos);
|
||||
|
||||
/**
|
||||
* Node Flags
|
||||
|
@ -172,6 +172,7 @@ class ByteArrayUtils {
|
||||
int codePoint = readCodePointAndAdvancePosition(buffer, pos);
|
||||
while (NOT_A_CODE_POINT != codePoint && length < maxLength) {
|
||||
codePoint = readCodePointAndAdvancePosition(buffer, pos);
|
||||
length++;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user