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

Commit c6704dbe authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi
Browse files

Add BinaryDictionary.flushWithGCIfHasUpdated().

Bug: 14166482
Bug: 14161647
Change-Id: I98b0a8b86897b1486491a3aea91729bc9e4cc03c
parent 7b43d987
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -460,6 +460,7 @@ public final class BinaryDictionary extends Dictionary {
                dictFile.length(), mIsUpdatable);
    }

    // Flush to dict file if the dictionary has been updated.
    public void flush() {
        if (!isValidDictionary()) return;
        if (mHasUpdated) {
@@ -468,6 +469,14 @@ public final class BinaryDictionary extends Dictionary {
        }
    }

    // Run GC and flush to dict file if the dictionary has been updated.
    public void flushWithGCIfHasUpdated() {
        if (mHasUpdated) {
            flushWithGC();
        }
    }

    // Run GC and flush to dict file.
    public void flushWithGC() {
        if (!isValidDictionary()) return;
        flushWithGCNative(mNativeDict, mDictFilePath);
+2 −1
Original line number Diff line number Diff line
@@ -515,7 +515,8 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
        createBinaryDictionaryLocked();
        openBinaryDictionaryLocked();
        loadInitialContentsLocked();
        mBinaryDictionary.flushWithGC();
        // Run GC and flush to file when initial contents have been loaded.
        mBinaryDictionary.flushWithGCIfHasUpdated();
    }

    private void flushDictionaryLocked() {