From f3897fb54e4e587f7d32514bebb2227c2c233f0f Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 4 Jul 2012 16:01:00 +0900 Subject: [PATCH] Get rid of redundant CharSequence member from SuggestedWordInfo Change-Id: Ie8792f4f5d3593c25c992fc72cf219daeaa70beb --- .../inputmethod/latin/SuggestedWords.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java index 94af301a2..f079c2112 100644 --- a/java/src/com/android/inputmethod/latin/SuggestedWords.java +++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java @@ -55,7 +55,7 @@ public class SuggestedWords { return mSuggestedWordInfoList.size(); } - public CharSequence getWord(int pos) { + public String getWord(int pos) { return mSuggestedWordInfoList.get(pos).mWord; } @@ -125,8 +125,7 @@ public class SuggestedWords { public static final int KIND_HARDCODED = 5; // Hardcoded suggestion, e.g. punctuation public static final int KIND_APP_DEFINED = 6; // Suggested by the application public static final int KIND_SHORTCUT = 7; // A shortcut - private final String mWordStr; - public final CharSequence mWord; + public final String mWord; public final int mScore; public final int mKind; // one of the KIND_* constants above public final int mCodePointCount; @@ -135,12 +134,11 @@ public class SuggestedWords { public SuggestedWordInfo(final CharSequence word, final int score, final int kind, final String sourceDict) { - mWordStr = word.toString(); - mWord = word; + mWord = word.toString(); mScore = score; mKind = kind; mSourceDict = sourceDict; - mCodePointCount = StringUtils.codePointCount(mWordStr); + mCodePointCount = StringUtils.codePointCount(mWord); } @@ -158,15 +156,15 @@ public class SuggestedWords { } public int codePointAt(int i) { - return mWordStr.codePointAt(i); + return mWord.codePointAt(i); } @Override public String toString() { if (TextUtils.isEmpty(mDebugString)) { - return mWordStr; + return mWord; } else { - return mWordStr + " (" + mDebugString.toString() + ")"; + return mWord + " (" + mDebugString.toString() + ")"; } } @@ -180,7 +178,7 @@ public class SuggestedWords { final SuggestedWordInfo cur = candidates.get(i); for (int j = 0; j < i; ++j) { final SuggestedWordInfo previous = candidates.get(j); - if (TextUtils.equals(cur.mWord, previous.mWord)) { + if (cur.mWord.equals(previous.mWord)) { candidates.remove(cur.mScore < previous.mScore ? i : j); --i; break;