* commit '72c870f5e67c0b332b8bf0b394796c28b53f61a7': Remove some unused variables.
This commit is contained in:
commit
aa3ae615d2
9 changed files with 25 additions and 41 deletions
|
@ -295,7 +295,6 @@ public final class BinaryDictDecoderUtils {
|
|||
return address;
|
||||
}
|
||||
}
|
||||
int address;
|
||||
switch (optionFlags & FormatSpec.MASK_CHILDREN_ADDRESS_TYPE) {
|
||||
case FormatSpec.FLAG_CHILDREN_ADDRESS_TYPE_ONEBYTE:
|
||||
return dictBuffer.readUnsignedByte();
|
||||
|
|
|
@ -278,7 +278,6 @@ public class BinaryDictEncoderUtils {
|
|||
// For future reference, the code to remove duplicate is a simple : list.remove(node);
|
||||
list.add(ptNodeArray);
|
||||
final ArrayList<PtNode> branches = ptNodeArray.mData;
|
||||
final int nodeSize = branches.size();
|
||||
for (PtNode ptNode : branches) {
|
||||
if (null != ptNode.mChildren) flattenTreeInner(list, ptNode.mChildren);
|
||||
}
|
||||
|
@ -427,9 +426,6 @@ public class BinaryDictEncoderUtils {
|
|||
nodeCountSize + nodeArrayOffset + nodeffset;
|
||||
nodeffset += ptNode.mCachedSize;
|
||||
}
|
||||
final int nodeSize = nodeCountSize + nodeffset
|
||||
+ (formatOptions.mSupportsDynamicUpdate
|
||||
? FormatSpec.FORWARD_LINK_ADDRESS_SIZE : 0);
|
||||
nodeArrayOffset += nodeArray.mCachedSize;
|
||||
}
|
||||
return nodeArrayOffset;
|
||||
|
@ -653,8 +649,8 @@ public class BinaryDictEncoderUtils {
|
|||
return flags;
|
||||
}
|
||||
|
||||
/* package */ static byte makePtNodeFlags(final PtNode node, final int ptNodeAddress,
|
||||
final int childrenOffset, final FormatOptions formatOptions) {
|
||||
/* package */ static byte makePtNodeFlags(final PtNode node, final int childrenOffset,
|
||||
final FormatOptions formatOptions) {
|
||||
return (byte) makePtNodeFlags(node.mChars.length > 1, node.mFrequency >= 0,
|
||||
getByteSize(childrenOffset),
|
||||
node.mShortcutTargets != null && !node.mShortcutTargets.isEmpty(),
|
||||
|
|
|
@ -59,7 +59,7 @@ public final class DynamicBinaryDictIOUtils {
|
|||
throws IOException, UnsupportedFormatException {
|
||||
final DictBuffer dictBuffer = dictDecoder.getDictBuffer();
|
||||
dictBuffer.position(0);
|
||||
final FileHeader header = dictDecoder.readHeader();
|
||||
dictDecoder.readHeader();
|
||||
final int wordPosition = dictDecoder.getTerminalPosition(word);
|
||||
if (wordPosition == FormatSpec.NOT_VALID_WORD) return;
|
||||
|
||||
|
@ -142,8 +142,7 @@ public final class DynamicBinaryDictIOUtils {
|
|||
final int originalPosition = dictBuffer.position();
|
||||
dictBuffer.position(ptNodeOriginAddress);
|
||||
final int flags = dictBuffer.readUnsignedByte();
|
||||
final int parentAddress = BinaryDictDecoderUtils.readParentAddress(dictBuffer,
|
||||
formatOptions);
|
||||
BinaryDictDecoderUtils.readParentAddress(dictBuffer, formatOptions);
|
||||
BinaryDictIOUtils.skipString(dictBuffer, (flags & FormatSpec.FLAG_HAS_MULTIPLE_CHARS) != 0);
|
||||
if ((flags & FormatSpec.FLAG_IS_TERMINAL) != 0) dictBuffer.readUnsignedByte();
|
||||
final int childrenOffset = newChildrenAddress == FormatSpec.NO_CHILDREN_ADDRESS
|
||||
|
|
|
@ -212,7 +212,6 @@ public class SparseTable {
|
|||
@UsedForTesting
|
||||
public static SparseTable readFromFiles(final File lookupTableFile, final File[] contentFiles,
|
||||
final int blockSize) throws IOException {
|
||||
final byte[] lookupTable = readFileToByteArray(lookupTableFile);
|
||||
final ArrayList<ArrayList<Integer>> contentTables =
|
||||
new ArrayList<ArrayList<Integer>>(contentFiles.length);
|
||||
for (int i = 0; i < contentFiles.length; ++i) {
|
||||
|
|
|
@ -133,12 +133,10 @@ public class Ver3DictEncoder implements DictEncoder {
|
|||
countSize);
|
||||
}
|
||||
|
||||
private void writePtNodeFlags(final PtNode ptNode, final int parentAddress,
|
||||
final FormatOptions formatOptions) {
|
||||
private void writePtNodeFlags(final PtNode ptNode, final FormatOptions formatOptions) {
|
||||
final int childrenPos = BinaryDictEncoderUtils.getChildrenPosition(ptNode, formatOptions);
|
||||
mPosition = BinaryDictEncoderUtils.writeUIntToBuffer(mBuffer, mPosition,
|
||||
BinaryDictEncoderUtils.makePtNodeFlags(ptNode, mPosition, childrenPos,
|
||||
formatOptions),
|
||||
BinaryDictEncoderUtils.makePtNodeFlags(ptNode, childrenPos, formatOptions),
|
||||
FormatSpec.PTNODE_FLAGS_SIZE);
|
||||
}
|
||||
|
||||
|
@ -244,7 +242,7 @@ public class Ver3DictEncoder implements DictEncoder {
|
|||
@Override
|
||||
public void writePtNode(final PtNode ptNode, final int parentPosition,
|
||||
final FormatOptions formatOptions, final FusionDictionary dict) {
|
||||
writePtNodeFlags(ptNode, parentPosition, formatOptions);
|
||||
writePtNodeFlags(ptNode, formatOptions);
|
||||
writeParentPosition(parentPosition, ptNode, formatOptions);
|
||||
writeCharacters(ptNode.mChars, ptNode.hasSeveralChars());
|
||||
writeFrequency(ptNode.mFrequency);
|
||||
|
|
|
@ -95,7 +95,6 @@ public class Ver4DictDecoder extends DictDecoder {
|
|||
|
||||
@Override
|
||||
public void openDictBuffer() throws FileNotFoundException, IOException {
|
||||
final String filename = mDictDirectory.getName();
|
||||
mDictBuffer = mBufferFactory.getDictionaryBuffer(getFile(FILETYPE_TRIE));
|
||||
mFrequencyBuffer = mBufferFactory.getDictionaryBuffer(getFile(FILETYPE_FREQUENCY));
|
||||
mTerminalAddressTableBuffer = mBufferFactory.getDictionaryBuffer(
|
||||
|
|
|
@ -181,12 +181,10 @@ public class Ver4DictEncoder implements DictEncoder {
|
|||
countSize);
|
||||
}
|
||||
|
||||
private void writePtNodeFlags(final PtNode ptNode, final int parentAddress,
|
||||
final FormatOptions formatOptions) {
|
||||
private void writePtNodeFlags(final PtNode ptNode, final FormatOptions formatOptions) {
|
||||
final int childrenPos = BinaryDictEncoderUtils.getChildrenPosition(ptNode, formatOptions);
|
||||
mTriePos = BinaryDictEncoderUtils.writeUIntToBuffer(mTrieBuf, mTriePos,
|
||||
BinaryDictEncoderUtils.makePtNodeFlags(ptNode, mTriePos, childrenPos,
|
||||
formatOptions),
|
||||
BinaryDictEncoderUtils.makePtNodeFlags(ptNode, childrenPos, formatOptions),
|
||||
FormatSpec.PTNODE_FLAGS_SIZE);
|
||||
}
|
||||
|
||||
|
@ -292,7 +290,7 @@ public class Ver4DictEncoder implements DictEncoder {
|
|||
@Override
|
||||
public void writePtNode(final PtNode ptNode, final int parentPosition,
|
||||
final FormatOptions formatOptions, final FusionDictionary dict) {
|
||||
writePtNodeFlags(ptNode, parentPosition, formatOptions);
|
||||
writePtNodeFlags(ptNode, formatOptions);
|
||||
writeParentPosition(parentPosition, ptNode, formatOptions);
|
||||
writeCharacters(ptNode.mChars, ptNode.hasSeveralChars());
|
||||
if (ptNode.isTerminal()) {
|
||||
|
|
|
@ -546,8 +546,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
private long checkGetTerminalPosition(final DictDecoder dictDecoder, final String word,
|
||||
int index, boolean contained) {
|
||||
final int expectedFrequency = (UNIGRAM_FREQ + index) % 255;
|
||||
final boolean contained) {
|
||||
long diff = -1;
|
||||
int position = -1;
|
||||
try {
|
||||
|
@ -605,7 +604,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
|
|||
// Test a word that is contained within the dictionary.
|
||||
long sum = 0;
|
||||
for (int i = 0; i < sWords.size(); ++i) {
|
||||
final long time = checkGetTerminalPosition(dictDecoder, sWords.get(i), i, true);
|
||||
final long time = checkGetTerminalPosition(dictDecoder, sWords.get(i), true);
|
||||
sum += time == -1 ? 0 : time;
|
||||
}
|
||||
Log.d(TAG, "per search : " + (((double)sum) / sWords.size() / 1000000) + " : " + message
|
||||
|
@ -618,11 +617,11 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
|
|||
for (int i = 0; i < 1000; ++i) {
|
||||
final String word = CodePointUtils.generateWord(random, codePointSet);
|
||||
if (sWords.indexOf(word) != -1) continue;
|
||||
checkGetTerminalPosition(dictDecoder, word, i, false);
|
||||
checkGetTerminalPosition(dictDecoder, word, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void runGetTerminalPositionTests(final ArrayList<String> results, final int bufferType,
|
||||
private void runGetTerminalPositionTests(final int bufferType,
|
||||
final FormatOptions formatOptions) {
|
||||
runGetTerminalPosition(sWords, sEmptyBigrams, bufferType, formatOptions, "unigram");
|
||||
}
|
||||
|
@ -630,17 +629,17 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
|
|||
public void testGetTerminalPosition() {
|
||||
final ArrayList<String> results = CollectionUtils.newArrayList();
|
||||
|
||||
runGetTerminalPositionTests(results, USE_BYTE_ARRAY, VERSION2);
|
||||
runGetTerminalPositionTests(results, USE_BYTE_ARRAY, VERSION3_WITHOUT_DYNAMIC_UPDATE);
|
||||
runGetTerminalPositionTests(results, USE_BYTE_ARRAY, VERSION3_WITH_DYNAMIC_UPDATE);
|
||||
runGetTerminalPositionTests(results, USE_BYTE_ARRAY, VERSION4_WITHOUT_DYNAMIC_UPDATE);
|
||||
runGetTerminalPositionTests(results, USE_BYTE_ARRAY, VERSION4_WITH_DYNAMIC_UPDATE);
|
||||
runGetTerminalPositionTests(USE_BYTE_ARRAY, VERSION2);
|
||||
runGetTerminalPositionTests(USE_BYTE_ARRAY, VERSION3_WITHOUT_DYNAMIC_UPDATE);
|
||||
runGetTerminalPositionTests(USE_BYTE_ARRAY, VERSION3_WITH_DYNAMIC_UPDATE);
|
||||
runGetTerminalPositionTests(USE_BYTE_ARRAY, VERSION4_WITHOUT_DYNAMIC_UPDATE);
|
||||
runGetTerminalPositionTests(USE_BYTE_ARRAY, VERSION4_WITH_DYNAMIC_UPDATE);
|
||||
|
||||
runGetTerminalPositionTests(results, USE_BYTE_BUFFER, VERSION2);
|
||||
runGetTerminalPositionTests(results, USE_BYTE_BUFFER, VERSION3_WITHOUT_DYNAMIC_UPDATE);
|
||||
runGetTerminalPositionTests(results, USE_BYTE_BUFFER, VERSION3_WITH_DYNAMIC_UPDATE);
|
||||
runGetTerminalPositionTests(results, USE_BYTE_BUFFER, VERSION4_WITHOUT_DYNAMIC_UPDATE);
|
||||
runGetTerminalPositionTests(results, USE_BYTE_BUFFER, VERSION4_WITH_DYNAMIC_UPDATE);
|
||||
runGetTerminalPositionTests(USE_BYTE_BUFFER, VERSION2);
|
||||
runGetTerminalPositionTests(USE_BYTE_BUFFER, VERSION3_WITHOUT_DYNAMIC_UPDATE);
|
||||
runGetTerminalPositionTests(USE_BYTE_BUFFER, VERSION3_WITH_DYNAMIC_UPDATE);
|
||||
runGetTerminalPositionTests(USE_BYTE_BUFFER, VERSION4_WITHOUT_DYNAMIC_UPDATE);
|
||||
runGetTerminalPositionTests(USE_BYTE_BUFFER, VERSION4_WITH_DYNAMIC_UPDATE);
|
||||
|
||||
for (final String result : results) {
|
||||
Log.d(TAG, result);
|
||||
|
|
|
@ -23,7 +23,6 @@ import android.util.Log;
|
|||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
@ -69,7 +68,7 @@ public class SparseTableTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
private void generateRandomIndex(final int size, final int prop) {
|
||||
for (int i = 0; i < DEFAULT_SIZE; ++i) {
|
||||
for (int i = 0; i < size; ++i) {
|
||||
if (mRandom.nextInt(100) < prop) {
|
||||
mRandomIndex.set(i, mRandom.nextInt());
|
||||
} else {
|
||||
|
@ -98,8 +97,6 @@ public class SparseTableTests extends AndroidTestCase {
|
|||
// flush and reload
|
||||
OutputStream lookupOutStream = null;
|
||||
OutputStream contentOutStream = null;
|
||||
InputStream lookupInStream = null;
|
||||
InputStream contentInStream = null;
|
||||
try {
|
||||
final File lookupIndexFile = File.createTempFile("testRandomSet", ".small");
|
||||
final File contentFile = File.createTempFile("testRandomSet", ".big");
|
||||
|
|
Loading…
Reference in a new issue