Loading native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp +6 −4 Original line number Original line Diff line number Diff line Loading @@ -126,7 +126,7 @@ int DynamicPatriciaTriePolicy::getTerminalNodePositionOfWord(const int *const in int pos = getRootPosition(); int pos = getRootPosition(); DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, getBigramsStructurePolicy(), DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, getBigramsStructurePolicy(), getShortcutsStructurePolicy()); getShortcutsStructurePolicy()); while (currentLength <= length) { while (currentLength < length) { // When foundMatchedNode becomes true, currentLength is increased at least once. // When foundMatchedNode becomes true, currentLength is increased at least once. bool foundMatchedNode = false; bool foundMatchedNode = false; int totalChildCount = 0; int totalChildCount = 0; Loading @@ -144,13 +144,15 @@ int DynamicPatriciaTriePolicy::getTerminalNodePositionOfWord(const int *const in for (int i = 0; i < childCount; i++) { for (int i = 0; i < childCount; i++) { nodeReader.fetchNodeInfoFromBufferAndGetNodeCodePoints(pos, MAX_WORD_LENGTH, nodeReader.fetchNodeInfoFromBufferAndGetNodeCodePoints(pos, MAX_WORD_LENGTH, mergedNodeCodePoints); mergedNodeCodePoints); if (nodeReader.isDeleted() || nodeReader.getCodePointCount() <= 0) { const int nodeCodePointCount = nodeReader.getCodePointCount(); if (nodeReader.isDeleted() || nodeCodePointCount <= 0 || currentLength + nodeCodePointCount > length) { // Skip deleted or empty node. // Skip deleted or empty node. pos = nodeReader.getSiblingNodePos(); pos = nodeReader.getSiblingNodePos(); continue; continue; } } bool matched = true; bool matched = true; for (int j = 0; j < nodeReader.getCodePointCount(); ++j) { for (int j = 0; j < nodeCodePointCount; ++j) { if (mergedNodeCodePoints[j] != searchCodePoints[currentLength + j]) { if (mergedNodeCodePoints[j] != searchCodePoints[currentLength + j]) { // Different code point is found. // Different code point is found. matched = false; matched = false; Loading @@ -158,7 +160,7 @@ int DynamicPatriciaTriePolicy::getTerminalNodePositionOfWord(const int *const in } } } } if (matched) { if (matched) { currentLength += nodeReader.getCodePointCount(); currentLength += nodeCodePointCount; if (length == currentLength) { if (length == currentLength) { // Terminal position is found. // Terminal position is found. return nodeReader.getNodePos(); return nodeReader.getNodePos(); Loading Loading
native/jni/src/suggest/policyimpl/dictionary/dynamic_patricia_trie_policy.cpp +6 −4 Original line number Original line Diff line number Diff line Loading @@ -126,7 +126,7 @@ int DynamicPatriciaTriePolicy::getTerminalNodePositionOfWord(const int *const in int pos = getRootPosition(); int pos = getRootPosition(); DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, getBigramsStructurePolicy(), DynamicPatriciaTrieNodeReader nodeReader(mDictRoot, getBigramsStructurePolicy(), getShortcutsStructurePolicy()); getShortcutsStructurePolicy()); while (currentLength <= length) { while (currentLength < length) { // When foundMatchedNode becomes true, currentLength is increased at least once. // When foundMatchedNode becomes true, currentLength is increased at least once. bool foundMatchedNode = false; bool foundMatchedNode = false; int totalChildCount = 0; int totalChildCount = 0; Loading @@ -144,13 +144,15 @@ int DynamicPatriciaTriePolicy::getTerminalNodePositionOfWord(const int *const in for (int i = 0; i < childCount; i++) { for (int i = 0; i < childCount; i++) { nodeReader.fetchNodeInfoFromBufferAndGetNodeCodePoints(pos, MAX_WORD_LENGTH, nodeReader.fetchNodeInfoFromBufferAndGetNodeCodePoints(pos, MAX_WORD_LENGTH, mergedNodeCodePoints); mergedNodeCodePoints); if (nodeReader.isDeleted() || nodeReader.getCodePointCount() <= 0) { const int nodeCodePointCount = nodeReader.getCodePointCount(); if (nodeReader.isDeleted() || nodeCodePointCount <= 0 || currentLength + nodeCodePointCount > length) { // Skip deleted or empty node. // Skip deleted or empty node. pos = nodeReader.getSiblingNodePos(); pos = nodeReader.getSiblingNodePos(); continue; continue; } } bool matched = true; bool matched = true; for (int j = 0; j < nodeReader.getCodePointCount(); ++j) { for (int j = 0; j < nodeCodePointCount; ++j) { if (mergedNodeCodePoints[j] != searchCodePoints[currentLength + j]) { if (mergedNodeCodePoints[j] != searchCodePoints[currentLength + j]) { // Different code point is found. // Different code point is found. matched = false; matched = false; Loading @@ -158,7 +160,7 @@ int DynamicPatriciaTriePolicy::getTerminalNodePositionOfWord(const int *const in } } } } if (matched) { if (matched) { currentLength += nodeReader.getCodePointCount(); currentLength += nodeCodePointCount; if (length == currentLength) { if (length == currentLength) { // Terminal position is found. // Terminal position is found. return nodeReader.getNodePos(); return nodeReader.getNodePos(); Loading