From 3b57631b60c696d407a73e7594f6ab2418932229 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Wed, 11 Jul 2012 16:47:22 +0900 Subject: [PATCH] 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 --- .../android/inputmethod/latin/BinaryDictionary.java | 2 -- java/src/com/android/inputmethod/latin/Suggest.java | 10 ++++------ native/jni/src/dictionary.h | 1 + 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 3b3315d3a..feff2f2c9 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -122,8 +122,6 @@ public class BinaryDictionary extends Dictionary { } } - // 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 31c6000e3..bbd415f68 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -194,12 +194,10 @@ public class Suggest { } 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 eb6cc9681..c8a21e0ae 100644 --- a/native/jni/src/dictionary.h +++ b/native/jni/src/dictionary.h @@ -60,6 +60,7 @@ class Dictionary { 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); }