aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorYuichiro Hanada <yhanada@google.com>2012-09-18 10:12:28 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-09-18 10:12:28 -0700
commit79939a5d1ae36df5ada0793d10dca9b36bf90901 (patch)
treed00e101713aff07b1151e3ac9e8410f2dcdaebe6 /java/src
parent7cef7b13e99692d3e0f55b4eda6ee11975287656 (diff)
parentea24d13c7ae5c8f1417a0165d806b47702eda07b (diff)
downloadlatinime-79939a5d1ae36df5ada0793d10dca9b36bf90901.tar.gz
latinime-79939a5d1ae36df5ada0793d10dca9b36bf90901.tar.xz
latinime-79939a5d1ae36df5ada0793d10dca9b36bf90901.zip
am ea24d13c: am bf45dc48: Make writePlacedNode write the linked-list node.
* commit 'ea24d13c7ae5c8f1417a0165d806b47702eda07b': Make writePlacedNode write the linked-list node.
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java23
1 files changed, 19 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
index 68d8bc553..3a5f24c86 100644
--- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
+++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java
@@ -370,6 +370,9 @@ public class BinaryDictInputOutput {
g.mCachedSize = groupSize;
size += groupSize;
}
+ if (options.mHasLinkedListNode) {
+ size += FormatSpec.FORWARD_LINK_ADDRESS_SIZE;
+ }
node.mCachedSize = size;
}
@@ -521,6 +524,9 @@ public class BinaryDictInputOutput {
group.mCachedSize = groupSize;
size += groupSize;
}
+ if (formatOptions.mHasLinkedListNode) {
+ size += FormatSpec.FORWARD_LINK_ADDRESS_SIZE;
+ }
if (node.mCachedSize != size) {
node.mCachedSize = size;
changed = true;
@@ -532,9 +538,11 @@ public class BinaryDictInputOutput {
* Computes the byte size of a list of nodes and updates each node cached position.
*
* @param flatNodes the array of nodes.
+ * @param formatOptions file format options.
* @return the byte size of the entire stack.
*/
- private static int stackNodes(final ArrayList<Node> flatNodes) {
+ private static int stackNodes(final ArrayList<Node> flatNodes,
+ final FormatOptions formatOptions) {
int nodeOffset = 0;
for (Node n : flatNodes) {
n.mCachedAddress = nodeOffset;
@@ -544,7 +552,9 @@ public class BinaryDictInputOutput {
g.mCachedAddress = groupCountSize + nodeOffset + groupOffset;
groupOffset += g.mCachedSize;
}
- if (groupOffset + groupCountSize != n.mCachedSize) {
+ final int nodeSize = groupCountSize + groupOffset
+ + (formatOptions.mHasLinkedListNode ? FormatSpec.FORWARD_LINK_ADDRESS_SIZE : 0);
+ if (nodeSize != n.mCachedSize) {
throw new RuntimeException("Bug : Stored and computed node size differ");
}
nodeOffset += n.mCachedSize;
@@ -571,7 +581,7 @@ public class BinaryDictInputOutput {
final ArrayList<Node> flatNodes, final FormatOptions formatOptions) {
// First get the worst sizes and offsets
for (Node n : flatNodes) setNodeMaximumSize(n, formatOptions);
- final int offset = stackNodes(flatNodes);
+ final int offset = stackNodes(flatNodes, formatOptions);
MakedictLog.i("Compressing the array addresses. Original size : " + offset);
MakedictLog.i("(Recursively seen size : " + offset + ")");
@@ -587,7 +597,7 @@ public class BinaryDictInputOutput {
if (oldNodeSize < newNodeSize) throw new RuntimeException("Increased size ?!");
changesDone |= changed;
}
- stackNodes(flatNodes);
+ stackNodes(flatNodes, formatOptions);
++passes;
if (passes > MAX_PASSES) throw new RuntimeException("Too many passes - probably a bug");
} while (changesDone);
@@ -910,6 +920,11 @@ public class BinaryDictInputOutput {
}
}
+ if (formatOptions.mHasLinkedListNode) {
+ buffer[index] = buffer[index + 1] = buffer[index + 2]
+ = FormatSpec.NO_FORWARD_LINK_ADDRESS;
+ index += FormatSpec.FORWARD_LINK_ADDRESS_SIZE;
+ }
if (index != node.mCachedAddress + node.mCachedSize) throw new RuntimeException(
"Not the same size : written "
+ (index - node.mCachedAddress) + " bytes out of a node that should have "