am 9261e4c0: Merge "Remove DicNode.managedDelete."
* commit '9261e4c08083fe5c60019e6a11ca3574abd8a886': Remove DicNode.managedDelete.main
commit
d6526de7f0
|
@ -83,14 +83,6 @@ class DicNode {
|
|||
#if DEBUG_DICT
|
||||
DicNodeProfiler mProfiler;
|
||||
#endif
|
||||
//////////////////
|
||||
// Memory utils //
|
||||
//////////////////
|
||||
AK_FORCE_INLINE static void managedDelete(DicNode *node) {
|
||||
node->remove();
|
||||
}
|
||||
// end
|
||||
/////////////////
|
||||
|
||||
AK_FORCE_INLINE DicNode()
|
||||
:
|
||||
|
@ -158,7 +150,7 @@ class DicNode {
|
|||
PROF_NODE_COPY(&dicNode->mProfiler, mProfiler);
|
||||
}
|
||||
|
||||
AK_FORCE_INLINE void remove() {
|
||||
AK_FORCE_INLINE void finalize() {
|
||||
mIsUsed = false;
|
||||
if (mReleaseListener) {
|
||||
mReleaseListener->onReleased(this);
|
||||
|
@ -478,17 +470,7 @@ class DicNode {
|
|||
mReleaseListener = releaseListener;
|
||||
}
|
||||
|
||||
AK_FORCE_INLINE bool compare(const DicNode *right) {
|
||||
if (!isUsed() && !right->isUsed()) {
|
||||
// Compare pointer values here for stable comparison
|
||||
return this > right;
|
||||
}
|
||||
if (!isUsed()) {
|
||||
return true;
|
||||
}
|
||||
if (!right->isUsed()) {
|
||||
return false;
|
||||
}
|
||||
AK_FORCE_INLINE bool compare(const DicNode *right) const {
|
||||
// Promote exact matches to prevent them from being pruned.
|
||||
const bool leftExactMatch = ErrorTypeUtils::isExactMatch(getContainedErrorTypes());
|
||||
const bool rightExactMatch = ErrorTypeUtils::isExactMatch(right->getContainedErrorTypes());
|
||||
|
|
|
@ -68,7 +68,7 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
|
|||
}
|
||||
setMaxSize(maxSize);
|
||||
for (int i = 0; i < mCapacity + 1; ++i) {
|
||||
mDicNodesBuf[i].remove();
|
||||
mDicNodesBuf[i].finalize();
|
||||
mDicNodesBuf[i].setReleaseListener(this);
|
||||
mUnusedNodeIndices[i] = i == mCapacity ? NOT_A_NODE_ID : static_cast<int>(i) + 1;
|
||||
}
|
||||
|
@ -89,11 +89,11 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
|
|||
if (dest) {
|
||||
DicNodeUtils::initByCopy(node, dest);
|
||||
}
|
||||
node->remove();
|
||||
node->finalize();
|
||||
mDicNodesQueue.pop();
|
||||
}
|
||||
|
||||
void onReleased(DicNode *dicNode) {
|
||||
void onReleased(const DicNode *dicNode) {
|
||||
const int index = static_cast<int>(dicNode - &mDicNodesBuf[0]);
|
||||
if (mUnusedNodeIndices[index] != NOT_A_NODE_ID) {
|
||||
// it's already released
|
||||
|
@ -190,7 +190,7 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
|
|||
mDicNodesQueue.push(dicNode);
|
||||
return dicNode;
|
||||
}
|
||||
dicNode->remove();
|
||||
dicNode->finalize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class DicNodeReleaseListener {
|
|||
public:
|
||||
DicNodeReleaseListener() {}
|
||||
virtual ~DicNodeReleaseListener() {}
|
||||
virtual void onReleased(DicNode *dicNode) = 0;
|
||||
virtual void onReleased(const DicNode *dicNode) = 0;
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(DicNodeReleaseListener);
|
||||
};
|
||||
|
|
|
@ -100,14 +100,7 @@ class DicNodesCache {
|
|||
}
|
||||
|
||||
AK_FORCE_INLINE void copyPushNextActive(DicNode *dicNode) {
|
||||
DicNode *pushedDicNode = mNextActiveDicNodes->copyPush(dicNode);
|
||||
if (!pushedDicNode) {
|
||||
if (dicNode->isCached()) {
|
||||
dicNode->remove();
|
||||
}
|
||||
// We simply drop any dic node that was not cached, ignoring the slim chance
|
||||
// that one of its children represents what the user really wanted.
|
||||
}
|
||||
mNextActiveDicNodes->copyPush(dicNode);
|
||||
}
|
||||
|
||||
void popTerminal(DicNode *dest) {
|
||||
|
|
|
@ -131,7 +131,6 @@ const int SuggestionsOutputUtils::MIN_LEN_FOR_MULTI_WORD_AUTOCORRECT = 16;
|
|||
true /* forceCommit */, boostExactMatches) : finalScore;
|
||||
outputShortcuts(&shortcutIt, shortcutBaseScore, sameAsTyped, outSuggestionResults);
|
||||
}
|
||||
DicNode::managedDelete(terminalDicNode);
|
||||
}
|
||||
scoringPolicy->getMostProbableString(traverseSession, languageWeight, outSuggestionResults);
|
||||
}
|
||||
|
|
|
@ -265,7 +265,6 @@ void Suggest::processExpandedDicNode(
|
|||
traverseSession->getDicTraverseCache()->copyPushNextActive(dicNode);
|
||||
}
|
||||
}
|
||||
DicNode::managedDelete(dicNode);
|
||||
}
|
||||
|
||||
void Suggest::processDicNodeAsMatch(DicTraverseSession *traverseSession,
|
||||
|
@ -388,7 +387,6 @@ void Suggest::processDicNodeAsTransposition(DicTraverseSession *traverseSession,
|
|||
processExpandedDicNode(traverseSession, childDicNode2);
|
||||
}
|
||||
}
|
||||
DicNode::managedDelete(childDicNodes1[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue