Move an implementation detail to native code (A107)

Java code does not have to know about this implementation detail:
the generic method should do the dispatching, instead of having
the caller call either method.

Change-Id: Ic13727f0cb18f4ced2c356cce2f8d710588c0421
main
Jean Chalard 2012-07-11 12:07:44 +09:00
parent 6a5d17cd2f
commit cc470c78e4
1 changed files with 11 additions and 4 deletions

View File

@ -147,10 +147,17 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object,
jint *prevWordChars = prevWordForBigrams
? env->GetIntArrayElements(prevWordForBigrams, 0) : 0;
jsize prevWordLength = prevWordChars ? env->GetArrayLength(prevWordForBigrams) : 0;
int count = dictionary->getSuggestions(pInfo, xCoordinates, yCoordinates, times, pointerIds,
inputCodes, arraySize, prevWordChars, prevWordLength, commitPoint, isGesture,
useFullEditDistance, (unsigned short*) outputChars,
frequencies, spaceIndices);
int count;
if (isGesture || arraySize > 1) {
count = dictionary->getSuggestions(pInfo, xCoordinates, yCoordinates, times, pointerIds,
inputCodes, arraySize, prevWordChars, prevWordLength, commitPoint, isGesture,
useFullEditDistance, (unsigned short*) outputChars, frequencies, spaceIndices);
} else {
count = dictionary->getBigrams(prevWordChars, prevWordLength, inputCodes,
arraySize, (unsigned short*) outputChars, frequencies);
}
if (prevWordChars) {
env->ReleaseIntArrayElements(prevWordForBigrams, prevWordChars, JNI_ABORT);
}