From 12efad3d15147f255f6e01600c40e9fdb1224d84 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Fri, 11 May 2012 22:51:34 +0900 Subject: [PATCH] Some more obvious optimizations The speedup is about 15% Bug: 6394357 Change-Id: Ibd57363d9d793206dd916d8927366db4192083b6 --- .../inputmethod/latin/makedict/FusionDictionary.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java index 55ceb1ca4..c467ef7d4 100644 --- a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java +++ b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java @@ -507,21 +507,21 @@ public class FusionDictionary implements Iterable { */ public static CharGroup findWordInTree(Node node, final String s) { int index = 0; - final StringBuilder checker = new StringBuilder(); + final StringBuilder checker = DBG ? new StringBuilder() : null; CharGroup currentGroup; do { int indexOfGroup = findIndexOfChar(node, s.codePointAt(index)); if (CHARACTER_NOT_FOUND == indexOfGroup) return null; 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; if (index < s.length()) { node = currentGroup.mChildren; } } while (null != node && index < s.length()); - if (!s.equals(checker.toString())) return null; + if (DBG && !s.equals(checker.toString())) return null; return currentGroup; }