Some more obvious optimizations
The speedup is about 15% Bug: 6394357 Change-Id: Ibd57363d9d793206dd916d8927366db4192083b6
This commit is contained in:
parent
47db0be7cb
commit
12efad3d15
1 changed files with 3 additions and 3 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue