From 6c48efb4b641f05e6b5bbb5697e8660d17b7ff52 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Reimar=20D=C3=B6ffinger?= Date: Sun, 10 Dec 2017 23:33:04 +0100 Subject: [PATCH] Skippable optimization also for HtmlEntry. --- .../android/dictionary/engine/Dictionary.java | 2 +- .../android/dictionary/engine/HtmlEntry.java | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/com/hughes/android/dictionary/engine/Dictionary.java b/src/com/hughes/android/dictionary/engine/Dictionary.java index 4543b7b..dfac548 100644 --- a/src/com/hughes/android/dictionary/engine/Dictionary.java +++ b/src/com/hughes/android/dictionary/engine/Dictionary.java @@ -95,7 +95,7 @@ public class Dictionary implements RAFSerializable { if (dictFileVersion >= 5) { htmlEntries = CachingList.create( RAFList.create(ch, new HtmlEntry.Serializer(this, ch), ch.position(), dictFileVersion, dictInfo + " html: "), - CACHE_SIZE, true); + CACHE_SIZE, false); } else { htmlEntries = Collections.emptyList(); } diff --git a/src/com/hughes/android/dictionary/engine/HtmlEntry.java b/src/com/hughes/android/dictionary/engine/HtmlEntry.java index f69a325..c12091b 100644 --- a/src/com/hughes/android/dictionary/engine/HtmlEntry.java +++ b/src/com/hughes/android/dictionary/engine/HtmlEntry.java @@ -3,6 +3,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.ibm.icu.text.Transliterator; import java.io.DataInput; @@ -71,7 +72,7 @@ public class HtmlEntry extends AbstractEntry implements Comparable { return new Row(this.index, rowIndex, dictionaryIndex); } - static final class Serializer implements RAFListSerializer { + static final class Serializer implements RAFListSerializerSkippable { final Dictionary dictionary; final FileChannel ch; @@ -86,6 +87,20 @@ public class HtmlEntry extends AbstractEntry implements Comparable { return new HtmlEntry(dictionary, ch, raf, index); } + @Override + public void skip(DataInput raf, final int index) throws IOException { + if (dictionary.dictFileVersion >= 7) + { + StringUtil.readVarInt(raf); + } + else + { + raf.skipBytes(2); + } + int l = raf.readUnsignedShort(); + raf.skipBytes(l); + } + @Override public void write(DataOutput raf, HtmlEntry t) throws IOException { t.writeBase(raf); -- 2.43.0