Small optimizations
Bug: 6394357 Change-Id: I00ba1b5ab3d527b3768e28090c758ddd1629f281
This commit is contained in:
parent
3b1b72ac4d
commit
4df5b43df8
1 changed files with 6 additions and 4 deletions
|
@ -40,6 +40,8 @@ import java.util.TreeMap;
|
||||||
*/
|
*/
|
||||||
public class BinaryDictInputOutput {
|
public class BinaryDictInputOutput {
|
||||||
|
|
||||||
|
final static boolean DBG = MakedictLog.DBG;
|
||||||
|
|
||||||
/* Node layout is as follows:
|
/* Node layout is as follows:
|
||||||
* | addressType xx : mask with MASK_GROUP_ADDRESS_TYPE
|
* | addressType xx : mask with MASK_GROUP_ADDRESS_TYPE
|
||||||
* 2 bits, 00 = no children : FLAG_GROUP_ADDRESS_TYPE_NOADDRESS
|
* 2 bits, 00 = no children : FLAG_GROUP_ADDRESS_TYPE_NOADDRESS
|
||||||
|
@ -715,13 +717,13 @@ public class BinaryDictInputOutput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (null != group.mShortcutTargets) {
|
if (null != group.mShortcutTargets) {
|
||||||
if (0 == group.mShortcutTargets.size()) {
|
if (DBG && 0 == group.mShortcutTargets.size()) {
|
||||||
throw new RuntimeException("0-sized shortcut list must be null");
|
throw new RuntimeException("0-sized shortcut list must be null");
|
||||||
}
|
}
|
||||||
flags |= FLAG_HAS_SHORTCUT_TARGETS;
|
flags |= FLAG_HAS_SHORTCUT_TARGETS;
|
||||||
}
|
}
|
||||||
if (null != group.mBigrams) {
|
if (null != group.mBigrams) {
|
||||||
if (0 == group.mBigrams.size()) {
|
if (DBG && 0 == group.mBigrams.size()) {
|
||||||
throw new RuntimeException("0-sized bigram list must be null");
|
throw new RuntimeException("0-sized bigram list must be null");
|
||||||
}
|
}
|
||||||
flags |= FLAG_HAS_BIGRAMS;
|
flags |= FLAG_HAS_BIGRAMS;
|
||||||
|
@ -830,7 +832,7 @@ public class BinaryDictInputOutput {
|
||||||
+ index + " <> " + group.mCachedAddress);
|
+ index + " <> " + group.mCachedAddress);
|
||||||
groupAddress += GROUP_FLAGS_SIZE + getGroupCharactersSize(group);
|
groupAddress += GROUP_FLAGS_SIZE + getGroupCharactersSize(group);
|
||||||
// Sanity checks.
|
// Sanity checks.
|
||||||
if (group.mFrequency > MAX_TERMINAL_FREQUENCY) {
|
if (DBG && group.mFrequency > MAX_TERMINAL_FREQUENCY) {
|
||||||
throw new RuntimeException("A node has a frequency > " + MAX_TERMINAL_FREQUENCY
|
throw new RuntimeException("A node has a frequency > " + MAX_TERMINAL_FREQUENCY
|
||||||
+ " : " + group.mFrequency);
|
+ " : " + group.mFrequency);
|
||||||
}
|
}
|
||||||
|
@ -1037,7 +1039,7 @@ public class BinaryDictInputOutput {
|
||||||
MakedictLog.i("Computing addresses...");
|
MakedictLog.i("Computing addresses...");
|
||||||
computeAddresses(dict, flatNodes);
|
computeAddresses(dict, flatNodes);
|
||||||
MakedictLog.i("Checking array...");
|
MakedictLog.i("Checking array...");
|
||||||
checkFlatNodeArray(flatNodes);
|
if (DBG) checkFlatNodeArray(flatNodes);
|
||||||
|
|
||||||
// Create a buffer that matches the final dictionary size.
|
// Create a buffer that matches the final dictionary size.
|
||||||
final Node lastNode = flatNodes.get(flatNodes.size() - 1);
|
final Node lastNode = flatNodes.get(flatNodes.size() - 1);
|
||||||
|
|
Loading…
Reference in a new issue