am f184e73d: Merge "Some more obvious optimizations" into jb-dev

* commit 'f184e73dd77464c53cbfe2815916e826cd32f318':
  Some more obvious optimizations
main
Jean Chalard 2012-05-15 11:37:49 -07:00 committed by Android Git Automerger
commit 16c34b1bc5
1 changed files with 3 additions and 3 deletions

View File

@ -507,21 +507,21 @@ public class FusionDictionary implements Iterable<Word> {
*/ */
public static CharGroup findWordInTree(Node node, final String s) { public static CharGroup findWordInTree(Node node, final String s) {
int index = 0; int index = 0;
final StringBuilder checker = new StringBuilder(); final StringBuilder checker = DBG ? new StringBuilder() : null;
CharGroup currentGroup; CharGroup currentGroup;
do { do {
int indexOfGroup = findIndexOfChar(node, s.codePointAt(index)); int indexOfGroup = findIndexOfChar(node, s.codePointAt(index));
if (CHARACTER_NOT_FOUND == indexOfGroup) return null; if (CHARACTER_NOT_FOUND == indexOfGroup) return null;
currentGroup = node.mData.get(indexOfGroup); currentGroup = node.mData.get(indexOfGroup);
checker.append(new String(currentGroup.mChars, 0, currentGroup.mChars.length)); if (DBG) checker.append(new String(currentGroup.mChars, 0, currentGroup.mChars.length));
index += currentGroup.mChars.length; index += currentGroup.mChars.length;
if (index < s.length()) { if (index < s.length()) {
node = currentGroup.mChildren; node = currentGroup.mChildren;
} }
} while (null != node && index < s.length()); } while (null != node && index < s.length());
if (!s.equals(checker.toString())) return null; if (DBG && !s.equals(checker.toString())) return null;
return currentGroup; return currentGroup;
} }