diff options
author | 2014-03-10 17:57:53 +0900 | |
---|---|---|
committer | 2014-03-10 17:57:53 +0900 | |
commit | 632c9aca5bbae49be278cf3e88d12b364fbd6fc8 (patch) | |
tree | e19b49efd55748a2b82fb717c8d652101a14c24b /native/jni/src/suggest/core/suggest.cpp | |
parent | 87db47d175cab854585c209d929628ce4ae25d8d (diff) | |
download | latinime-632c9aca5bbae49be278cf3e88d12b364fbd6fc8.tar.gz latinime-632c9aca5bbae49be278cf3e88d12b364fbd6fc8.tar.xz latinime-632c9aca5bbae49be278cf3e88d12b364fbd6fc8.zip |
Improve DicNode handling.
- Stop creating useless DicNode and DicNodeVector.
- Remove useless virtual.
- Implement copy constructor and assignment operator of DicNodeState.
- Remove useless memset.
Before:
(0) 2266.21 (0.79%)
(1) 285422.05 (98.97%)
(2) 642.62 (0.22%)
(66) 0.19 (0.00%)
Total 288384.35 (sum of others 288331.07)
After:
(0) 2232.70 (0.86%)
(1) 255258.50 (98.89%)
(2) 585.73 (0.23%)
(66) 0.26 (0.00%)
Total 258126.46 (sum of others 258077.18)
Change-Id: I0bb1e9de8b38a6743a11aaeb2b17bd0da5b7ad34
Diffstat (limited to 'native/jni/src/suggest/core/suggest.cpp')
-rw-r--r-- | native/jni/src/suggest/core/suggest.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/native/jni/src/suggest/core/suggest.cpp b/native/jni/src/suggest/core/suggest.cpp index c3b670337..f60a210d4 100644 --- a/native/jni/src/suggest/core/suggest.cpp +++ b/native/jni/src/suggest/core/suggest.cpp @@ -248,17 +248,16 @@ void Suggest::processTerminalDicNode( if (dicNode->shouldBeFilteredBySafetyNetForBigram()) { return; } + if (!dicNode->hasMatchedOrProximityCodePoints()) { + return; + } // Create a non-cached node here. - DicNode terminalDicNode; - DicNodeUtils::initByCopy(dicNode, &terminalDicNode); + DicNode terminalDicNode(*dicNode); if (TRAVERSAL->needsToTraverseAllUserInput() && dicNode->getInputIndex(0) < traverseSession->getInputSize()) { Weighting::addCostAndForwardInputIndex(WEIGHTING, CT_TERMINAL_INSERTION, traverseSession, 0, &terminalDicNode, traverseSession->getMultiBigramMap()); } - if (!dicNode->hasMatchedOrProximityCodePoints()) { - return; - } Weighting::addCostAndForwardInputIndex(WEIGHTING, CT_TERMINAL, traverseSession, 0, &terminalDicNode, traverseSession->getMultiBigramMap()); traverseSession->getDicTraverseCache()->copyPushTerminal(&terminalDicNode); @@ -375,6 +374,7 @@ void Suggest::processDicNodeAsTransposition(DicTraverseSession *traverseSession, DicNode *dicNode) const { const int16_t pointIndex = dicNode->getInputIndex(0); DicNodeVector childDicNodes1; + DicNodeVector childDicNodes2; DicNodeUtils::getAllChildDicNodes(dicNode, traverseSession->getDictionaryStructurePolicy(), &childDicNodes1); const int childSize1 = childDicNodes1.getSizeAndLock(); @@ -386,7 +386,7 @@ void Suggest::processDicNodeAsTransposition(DicTraverseSession *traverseSession, continue; } if (childDicNodes1[i]->hasChildren()) { - DicNodeVector childDicNodes2; + childDicNodes2.clear(); DicNodeUtils::getAllChildDicNodes(childDicNodes1[i], traverseSession->getDictionaryStructurePolicy(), &childDicNodes2); const int childSize2 = childDicNodes2.getSizeAndLock(); |