Avoid string conversions when possible.

Change-Id: Ibf5f3e40da55998364d0d835ecf283f32c80fcf5
main
Jean Chalard 2012-06-26 19:39:28 +09:00
parent bed514bd90
commit 5953dc93cf
1 changed files with 4 additions and 4 deletions

View File

@ -390,7 +390,7 @@ public class Suggest {
int dataTypeForLog = dataType; int dataTypeForLog = dataType;
final int prefMaxSuggestions = MAX_SUGGESTIONS; final int prefMaxSuggestions = MAX_SUGGESTIONS;
final String word = wordInfo.mWord.toString(); final CharSequence word = wordInfo.mWord;
final int score = wordInfo.mScore; final int score = wordInfo.mScore;
int pos = 0; int pos = 0;
@ -413,7 +413,7 @@ public class Suggest {
// Check the last one's score and bail // Check the last one's score and bail
if (suggestions.size() >= prefMaxSuggestions if (suggestions.size() >= prefMaxSuggestions
&& suggestions.get(prefMaxSuggestions - 1).mScore >= score) return true; && suggestions.get(prefMaxSuggestions - 1).mScore >= score) return true;
final int length = word.codePointCount(0, word.length()); final int length = Character.codePointCount(word, 0, word.length());
while (pos < suggestions.size()) { while (pos < suggestions.size()) {
final int curScore = suggestions.get(pos).mScore; final int curScore = suggestions.get(pos).mScore;
if (curScore < score if (curScore < score
@ -429,9 +429,9 @@ public class Suggest {
final StringBuilder sb = new StringBuilder(getApproxMaxWordLength()); final StringBuilder sb = new StringBuilder(getApproxMaxWordLength());
if (mIsAllUpperCase) { if (mIsAllUpperCase) {
sb.append(word.toUpperCase(mLocale)); sb.append(word.toString().toUpperCase(mLocale));
} else if (mIsFirstCharCapitalized) { } else if (mIsFirstCharCapitalized) {
sb.append(StringUtils.toTitleCase(word, mLocale)); sb.append(StringUtils.toTitleCase(word.toString(), mLocale));
} else { } else {
sb.append(word); sb.append(word);
} }