Loading java/src/com/android/inputmethod/latin/BinaryDictionary.java +10 −4 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -270,7 +270,7 @@ public final class BinaryDictionary extends Dictionary { } private void runGCIfRequired() { if (needsToRunGCNative(mNativeDict)) { if (needsToRunGC(true /* mindsBlockByGC */)) { flushWithGC(); } } Loading Loading @@ -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 Loading java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +1 −1 Original line number Diff line number Diff line Loading @@ -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(); Loading native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -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, Loading Loading @@ -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) }, { Loading native/jni/src/suggest/core/dictionary/dictionary.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -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, Loading native/jni/src/suggest/core/dictionary/dictionary.h +1 −1 Original line number Diff line number Diff line Loading @@ -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 Loading
java/src/com/android/inputmethod/latin/BinaryDictionary.java +10 −4 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -270,7 +270,7 @@ public final class BinaryDictionary extends Dictionary { } private void runGCIfRequired() { if (needsToRunGCNative(mNativeDict)) { if (needsToRunGC(true /* mindsBlockByGC */)) { flushWithGC(); } } Loading Loading @@ -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 Loading
java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +1 −1 Original line number Diff line number Diff line Loading @@ -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(); Loading
native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -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, Loading Loading @@ -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) }, { Loading
native/jni/src/suggest/core/dictionary/dictionary.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -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, Loading
native/jni/src/suggest/core/dictionary/dictionary.h +1 −1 Original line number Diff line number Diff line Loading @@ -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