Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9261e4c0 authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi Committed by Android (Google) Code Review
Browse files

Merge "Remove DicNode.managedDelete."

parents a4c5c54a 144b9a63
Loading
Loading
Loading
Loading
+2 −20
Original line number Diff line number Diff line
@@ -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());
+4 −4
Original line number Diff line number Diff line
@@ -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;
    }

+1 −1
Original line number Diff line number Diff line
@@ -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);
};
+1 −8
Original line number Diff line number Diff line
@@ -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) {
+0 −1
Original line number Diff line number Diff line
@@ -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);
}
Loading