diff options
Diffstat (limited to 'native/jni/src/suggest/core/dicnode')
5 files changed, 0 insertions, 91 deletions
diff --git a/native/jni/src/suggest/core/dicnode/dic_node.h b/native/jni/src/suggest/core/dicnode/dic_node.h index 82b738d36..ae228fb98 100644 --- a/native/jni/src/suggest/core/dicnode/dic_node.h +++ b/native/jni/src/suggest/core/dicnode/dic_node.h @@ -284,33 +284,6 @@ class DicNode { return prevWordsLen + currentWordDepth > MAX_WORD_LENGTH - 3; } - // TODO: This may be defective. Needs to be revised. - bool truncateNode(const DicNode *const topNode, const int inputCommitPoint) { - const int prevWordLenOfTop = mDicNodeState.mDicNodeStatePrevWord.getPrevWordLength(); - int newPrevWordStartIndex = inputCommitPoint; - int charCount = 0; - // Find new word start index - for (int i = 0; i < prevWordLenOfTop; ++i) { - const int c = mDicNodeState.mDicNodeStatePrevWord.getPrevWordCodePointAt(i); - // TODO: Check other separators. - if (c != KEYCODE_SPACE && c != KEYCODE_SINGLE_QUOTE) { - if (charCount == inputCommitPoint) { - newPrevWordStartIndex = i; - break; - } - ++charCount; - } - } - if (!mDicNodeState.mDicNodeStatePrevWord.startsWith( - &topNode->mDicNodeState.mDicNodeStatePrevWord, newPrevWordStartIndex - 1)) { - // Node mismatch. - return false; - } - mDicNodeState.mDicNodeStateInput.truncate(inputCommitPoint); - mDicNodeState.mDicNodeStatePrevWord.truncate(newPrevWordStartIndex); - return true; - } - void outputResult(int *dest) const { const uint16_t prevWordLength = mDicNodeState.mDicNodeStatePrevWord.getPrevWordLength(); const uint16_t currentDepth = getNodeCodePointCount(); diff --git a/native/jni/src/suggest/core/dicnode/dic_nodes_cache.cpp b/native/jni/src/suggest/core/dicnode/dic_nodes_cache.cpp index b6be47e90..ef4a6b5d8 100644 --- a/native/jni/src/suggest/core/dicnode/dic_nodes_cache.cpp +++ b/native/jni/src/suggest/core/dicnode/dic_nodes_cache.cpp @@ -28,37 +28,4 @@ const int DicNodesCache::LARGE_PRIORITY_QUEUE_CAPACITY = 310; // Capacity for reducing memory footprint. const int DicNodesCache::SMALL_PRIORITY_QUEUE_CAPACITY = 100; -/** - * Truncates all of the dicNodes so that they start at the given commit point. - * Only called for multi-word typing input. - */ -DicNode *DicNodesCache::setCommitPoint(int commitPoint) { - std::list<DicNode> dicNodesList; - while (mCachedDicNodesForContinuousSuggestion->getSize() > 0) { - DicNode dicNode; - mCachedDicNodesForContinuousSuggestion->copyPop(&dicNode); - dicNodesList.push_front(dicNode); - } - - // Get the starting words of the top scoring dicNode (last dicNode popped from priority queue) - // up to the commit point. These words have already been committed to the text view. - DicNode *topDicNode = &dicNodesList.front(); - DicNode topDicNodeCopy; - DicNodeUtils::initByCopy(topDicNode, &topDicNodeCopy); - - // Keep only those dicNodes that match the same starting words. - std::list<DicNode>::iterator iter; - for (iter = dicNodesList.begin(); iter != dicNodesList.end(); iter++) { - DicNode *dicNode = &*iter; - if (dicNode->truncateNode(&topDicNodeCopy, commitPoint)) { - mCachedDicNodesForContinuousSuggestion->copyPush(dicNode); - } else { - // Top dicNode should be reprocessed. - ASSERT(dicNode != topDicNode); - DicNode::managedDelete(dicNode); - } - } - mInputIndex -= commitPoint; - return topDicNode; -} } // namespace latinime diff --git a/native/jni/src/suggest/core/dicnode/dic_nodes_cache.h b/native/jni/src/suggest/core/dicnode/dic_nodes_cache.h index c31c056f5..d4769e739 100644 --- a/native/jni/src/suggest/core/dicnode/dic_nodes_cache.h +++ b/native/jni/src/suggest/core/dicnode/dic_nodes_cache.h @@ -76,8 +76,6 @@ class DicNodesCache { moveNodesAndReturnReusableEmptyQueue(mNextActiveDicNodes, &mActiveDicNodes); } - DicNode *setCommitPoint(int commitPoint); - int activeSize() const { return mActiveDicNodes->getSize(); } int terminalSize() const { return mTerminalDicNodes->getSize(); } bool isLookAheadCorrectionInputIndex(const int inputIndex) const { diff --git a/native/jni/src/suggest/core/dicnode/internal/dic_node_state_input.h b/native/jni/src/suggest/core/dicnode/internal/dic_node_state_input.h index 3d788114f..03042a8a7 100644 --- a/native/jni/src/suggest/core/dicnode/internal/dic_node_state_input.h +++ b/native/jni/src/suggest/core/dicnode/internal/dic_node_state_input.h @@ -27,11 +27,6 @@ class DicNodeStateInput { DicNodeStateInput() {} ~DicNodeStateInput() {} - // TODO: Merge into DicNodeStatePrevWord::truncate - void truncate(const int commitPoint) { - mInputIndex[0] -= commitPoint; - } - void init() { for (int i = 0; i < MAX_POINTER_COUNT_G; i++) { // TODO: The initial value for mInputIndex should be -1? diff --git a/native/jni/src/suggest/core/dicnode/internal/dic_node_state_prevword.h b/native/jni/src/suggest/core/dicnode/internal/dic_node_state_prevword.h index f2b1ce8f7..409841e2d 100644 --- a/native/jni/src/suggest/core/dicnode/internal/dic_node_state_prevword.h +++ b/native/jni/src/suggest/core/dicnode/internal/dic_node_state_prevword.h @@ -70,18 +70,6 @@ class DicNodeStatePrevWord { mSecondWordFirstInputIndex = prevWordSecondWordFirstInputIndex; } - void truncate(const int offset) { - // TODO: memmove - if (mPrevWordLength < offset) { - memset(mPrevWord, 0, sizeof(mPrevWord)); - mPrevWordLength = 0; - return; - } - const int newPrevWordLength = mPrevWordLength - offset; - memmove(mPrevWord, &mPrevWord[offset], newPrevWordLength * sizeof(mPrevWord[0])); - mPrevWordLength = newPrevWordLength; - } - void setSecondWordFirstInputIndex(const int inputIndex) { mSecondWordFirstInputIndex = inputIndex; } @@ -111,18 +99,6 @@ class DicNodeStatePrevWord { return mPrevWord[id]; } - bool startsWith(const DicNodeStatePrevWord *const prefix, const int prefixLen) const { - if (prefixLen > mPrevWordLength) { - return false; - } - for (int i = 0; i < prefixLen; ++i) { - if (mPrevWord[i] != prefix->mPrevWord[i]) { - return false; - } - } - return true; - } - const int *getPrevWordBuf() const { return mPrevWord; } |