From: Reimar Döffinger Date: Sun, 10 Dec 2017 21:43:01 +0000 (+0100) Subject: Make use of the new skippable CachingList optimizations. X-Git-Url: http://gitweb.fperrin.net/?p=Dictionary.git;a=commitdiff_plain;h=0d6b69d8819c937eed8a911f491146b76a9b1300 Make use of the new skippable CachingList optimizations. --- diff --git a/Util b/Util index 23c6349..1923f0d 160000 --- a/Util +++ b/Util @@ -1 +1 @@ -Subproject commit 23c6349bd8331e34107a1bcb8e709be1b3ad0bb8 +Subproject commit 1923f0d7df985ebcf5a7bc01d8a2f9ceabd21550 diff --git a/src/com/hughes/android/dictionary/engine/Dictionary.java b/src/com/hughes/android/dictionary/engine/Dictionary.java index 3abe61e..4543b7b 100644 --- a/src/com/hughes/android/dictionary/engine/Dictionary.java +++ b/src/com/hughes/android/dictionary/engine/Dictionary.java @@ -88,14 +88,14 @@ public class Dictionary implements RAFSerializable { pairEntries = CachingList.create( RAFList.create(ch, new PairEntry.Serializer(this), ch.position(), dictFileVersion, dictInfo + " pairs: "), - CACHE_SIZE); + CACHE_SIZE, false); textEntries = CachingList.create( RAFList.create(ch, new TextEntry.Serializer(this), ch.position(), dictFileVersion, dictInfo + " text: "), - CACHE_SIZE); + CACHE_SIZE, true); if (dictFileVersion >= 5) { htmlEntries = CachingList.create( RAFList.create(ch, new HtmlEntry.Serializer(this, ch), ch.position(), dictFileVersion, dictInfo + " html: "), - CACHE_SIZE); + CACHE_SIZE, true); } else { htmlEntries = Collections.emptyList(); } diff --git a/src/com/hughes/android/dictionary/engine/Index.java b/src/com/hughes/android/dictionary/engine/Index.java index c254d30..99cdb54 100644 --- a/src/com/hughes/android/dictionary/engine/Index.java +++ b/src/com/hughes/android/dictionary/engine/Index.java @@ -136,7 +136,7 @@ public final class Index implements RAFSerializable { } sortedIndexEntries = CachingList.create( RAFList.create(inp, new IndexEntrySerializer(dict.dictFileVersion == 6 ? inp : null), inp.position(), - dict.dictFileVersion, dict.dictInfo + " idx " + languageCode + ": "), CACHE_SIZE); + dict.dictFileVersion, dict.dictInfo + " idx " + languageCode + ": "), CACHE_SIZE, true); if (dict.dictFileVersion >= 7) { int count = StringUtil.readVarInt(raf); stoplist = new HashSet(count); @@ -150,7 +150,7 @@ public final class Index implements RAFSerializable { } rows = CachingList.create( UniformRAFList.create(inp, new RowBase.Serializer(this), inp.position()), - CACHE_SIZE); + CACHE_SIZE, true); } @Override @@ -249,7 +249,7 @@ public final class Index implements RAFSerializable { this.htmlEntries = CachingList.create( RAFList.create(ch, index.dict.htmlEntryIndexSerializer, ch.position(), index.dict.dictFileVersion, - index.dict.dictInfo + " htmlEntries: "), 1); + index.dict.dictInfo + " htmlEntries: "), 1, false); } else { this.htmlEntries = Collections.emptyList(); } diff --git a/src/com/hughes/android/dictionary/engine/PairEntry.java b/src/com/hughes/android/dictionary/engine/PairEntry.java index 305f034..d3fb060 100644 --- a/src/com/hughes/android/dictionary/engine/PairEntry.java +++ b/src/com/hughes/android/dictionary/engine/PairEntry.java @@ -16,6 +16,7 @@ package com.hughes.android.dictionary.engine; import com.hughes.util.StringUtil; import com.hughes.util.raf.RAFListSerializer; +import com.hughes.util.raf.RAFListSerializerSkippable; import com.hughes.util.raf.RAFSerializable; import com.ibm.icu.text.Transliterator; @@ -63,7 +64,7 @@ public class PairEntry extends AbstractEntry implements RAFSerializable { + static final class Serializer implements RAFListSerializerSkippable { final Dictionary dictionary; @@ -76,6 +77,25 @@ public class PairEntry extends AbstractEntry implements RAFSerializable= 7) + { + StringUtil.readVarInt(raf); + size = StringUtil.readVarInt(raf); + } + else + { + raf.skipBytes(2); + size = raf.readInt(); + } + for (int i = 0; i < 2*size; ++i) { + int l = raf.readUnsignedShort(); + raf.skipBytes(l); + } + } + @Override public void write(DataOutput raf, PairEntry t) throws IOException { t.write(raf);