diff --git a/native/jni/src/suggest/core/policy/traversal.h b/native/jni/src/suggest/core/policy/traversal.h index d3b8da0cc13df086a1b19aca39b1bfe52221b7c3..8ddaa0514ac9c0047eaaccd335997c4a79b0d36a 100644 --- a/native/jni/src/suggest/core/policy/traversal.h +++ b/native/jni/src/suggest/core/policy/traversal.h @@ -45,6 +45,7 @@ class Traversal { virtual float getMaxSpatialDistance() const = 0; virtual int getDefaultExpandDicNodeSize() const = 0; virtual int getMaxCacheSize(const int inputSize) const = 0; + virtual int getTerminalCacheSize() const = 0; virtual bool isPossibleOmissionChildNode(const DicTraverseSession *const traverseSession, const DicNode *const parentDicNode, const DicNode *const dicNode) const = 0; virtual bool isGoodToTraverseNextWord(const DicNode *const dicNode) const = 0; diff --git a/native/jni/src/suggest/core/suggest.cpp b/native/jni/src/suggest/core/suggest.cpp index 433820a42d3d47995314d4e105a4d844f181f12f..e675e0bb30cac6ee272a2939d176c26536044a0b 100644 --- a/native/jni/src/suggest/core/suggest.cpp +++ b/native/jni/src/suggest/core/suggest.cpp @@ -88,7 +88,7 @@ void Suggest::initializeSearch(DicTraverseSession *traverseSession) const { } else { // Restart recognition at the root. traverseSession->resetCache(TRAVERSAL->getMaxCacheSize(traverseSession->getInputSize()), - MAX_RESULTS); + TRAVERSAL->getTerminalCacheSize()); // Create a new dic node here DicNode rootNode; DicNodeUtils::initAsRoot(traverseSession->getDictionaryStructurePolicy(), diff --git a/native/jni/src/suggest/policyimpl/typing/typing_traversal.h b/native/jni/src/suggest/policyimpl/typing/typing_traversal.h index 5ba8bfa0104a559fa83d776669c7c1b0d6640734..cb3dfac7089493535e383e561d26193c47446b7b 100644 --- a/native/jni/src/suggest/policyimpl/typing/typing_traversal.h +++ b/native/jni/src/suggest/policyimpl/typing/typing_traversal.h @@ -146,6 +146,10 @@ class TypingTraversal : public Traversal { : ScoringParams::MAX_CACHE_DIC_NODE_SIZE; } + AK_FORCE_INLINE int getTerminalCacheSize() const { + return MAX_RESULTS; + } + AK_FORCE_INLINE bool isPossibleOmissionChildNode( const DicTraverseSession *const traverseSession, const DicNode *const parentDicNode, const DicNode *const dicNode) const {