Resolve a TODO: bury some implementation detail in native (A110)
The fact that prediction does not accept a null argument is an
implementation detail, it should not be visible to Java code.
Change-Id: I3a156b323b6db9353de898d33f3f7c81751cecb1
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index 3b3315d..feff2f2 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -122,8 +122,6 @@
}
}
- // TODO: move this test to native code.
- if (composerSize <= 1 && TextUtils.isEmpty(prevWord)) return null;
final InputPointers ips = composer.getInputPointers();
final int codesSize = isGesture ? ips.getPointerSize() : composerSize;
// proximityInfo and/or prevWordForBigrams may not be null.
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 31c6000..bbd415f 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -194,12 +194,10 @@
}
if (wordComposerForLookup.size() <= 1) {
// At first character typed, search only the bigrams
- if (!TextUtils.isEmpty(prevWordForBigram)) {
- for (final String key : mDictionaries.keySet()) {
- final Dictionary dictionary = mDictionaries.get(key);
- suggestionsSet.addAll(dictionary.getSuggestions(wordComposerForLookup,
- prevWordForBigram, proximityInfo));
- }
+ for (final String key : mDictionaries.keySet()) {
+ final Dictionary dictionary = mDictionaries.get(key);
+ suggestionsSet.addAll(dictionary.getSuggestions(
+ wordComposerForLookup, prevWordForBigram, proximityInfo));
}
} else {
// At second character typed, search the unigrams (scores being affected by bigrams)
diff --git a/native/jni/src/dictionary.h b/native/jni/src/dictionary.h
index eb6cc96..c8a21e0 100644
--- a/native/jni/src/dictionary.h
+++ b/native/jni/src/dictionary.h
@@ -60,6 +60,7 @@
int getBigrams(const int32_t *word, int length, int *codes, int codesSize,
unsigned short *outWords, int *frequencies) const {
+ if (length <= 0) return 0;
return mBigramDictionary->getBigrams(word, length, codes, codesSize, outWords, frequencies);
}