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

Commit 4c677d7b authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi Committed by Android Git Automerger
Browse files

am 0aaf42b4: am c1851004: Prepare dictionary decay.

* commit '0aaf42b4':
  Prepare dictionary decay.
parents 72e6932d 0aaf42b4
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ public final class BinaryDictionary extends Dictionary {
    private static native long openNative(String sourceDir, long dictOffset, long dictSize,
            boolean isUpdatable);
    private static native void flushNative(long dict, String filePath);
    private static native boolean needsToRunGCNative(long dict);
    private static native boolean needsToRunGCNative(long dict, boolean mindsBlockByGC);
    private static native void flushWithGCNative(long dict, String filePath);
    private static native void closeNative(long dict);
    private static native int getProbabilityNative(long dict, int[] word);
@@ -270,7 +270,7 @@ public final class BinaryDictionary extends Dictionary {
    }

    private void runGCIfRequired() {
        if (needsToRunGCNative(mNativeDict)) {
        if (needsToRunGC(true /* mindsBlockByGC */)) {
            flushWithGC();
        }
    }
@@ -326,9 +326,15 @@ public final class BinaryDictionary extends Dictionary {
        reopen();
    }

    public boolean needsToRunGC() {
    /**
     * Checks whether GC is needed to run or not.
     * @param mindsBlockByGC Whether to mind operations blocked by GC. We don't need to care about
     * the blocking in some situations such as in idle time or just before closing.
     * @return whether GC is needed to run or not.
     */
    public boolean needsToRunGC(final boolean mindsBlockByGC) {
        if (!isValidDictionary()) return false;
        return needsToRunGCNative(mNativeDict);
        return needsToRunGCNative(mNativeDict, mindsBlockByGC);
    }

    @UsedForTesting
+1 −1
Original line number Diff line number Diff line
@@ -505,7 +505,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
                    BinaryDictionary.createEmptyDictFile(file.getAbsolutePath(),
                            DICTIONARY_FORMAT_VERSION, getHeaderAttributeMap());
                } else {
                    if (mBinaryDictionary.needsToRunGC()) {
                    if (mBinaryDictionary.needsToRunGC(false /* mindsBlockByGC */)) {
                        mBinaryDictionary.flushWithGC();
                    } else {
                        mBinaryDictionary.flush();
+3 −3
Original line number Diff line number Diff line
@@ -113,10 +113,10 @@ static void latinime_BinaryDictionary_flush(JNIEnv *env, jclass clazz, jlong dic
}

static bool latinime_BinaryDictionary_needsToRunGC(JNIEnv *env, jclass clazz,
        jlong dict) {
        jlong dict, jboolean mindsBlockByGC) {
    Dictionary *dictionary = reinterpret_cast<Dictionary *>(dict);
    if (!dictionary) return false;
    return dictionary->needsToRunGC();
    return dictionary->needsToRunGC(mindsBlockByGC == JNI_TRUE);
}

static void latinime_BinaryDictionary_flushWithGC(JNIEnv *env, jclass clazz, jlong dict,
@@ -364,7 +364,7 @@ static const JNINativeMethod sMethods[] = {
    },
    {
        const_cast<char *>("needsToRunGCNative"),
        const_cast<char *>("(J)Z"),
        const_cast<char *>("(JZ)Z"),
        reinterpret_cast<void *>(latinime_BinaryDictionary_needsToRunGC)
    },
    {
+2 −2
Original line number Diff line number Diff line
@@ -123,8 +123,8 @@ void Dictionary::flushWithGC(const char *const filePath) {
    mDictionaryStructureWithBufferPolicy->flushWithGC(filePath);
}

bool Dictionary::needsToRunGC() {
    return mDictionaryStructureWithBufferPolicy->needsToRunGC();
bool Dictionary::needsToRunGC(const bool mindsBlockByGC) {
    return mDictionaryStructureWithBufferPolicy->needsToRunGC(mindsBlockByGC);
}

void Dictionary::getProperty(const char *const query, char *const outResult,
+1 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ class Dictionary {

    void flushWithGC(const char *const filePath);

    bool needsToRunGC();
    bool needsToRunGC(const bool mindsBlockByGC);

    void getProperty(const char *const query, char *const outResult,
            const int maxResultLength) const;
Loading