From 6e26cc3f5d7f3f7d2f2f28e53bc9986d6236df79 Mon Sep 17 00:00:00 2001 From: Yuichiro Hanada Date: Fri, 16 Aug 2013 17:10:45 +0900 Subject: [PATCH] Remove unnecessary caching. Change-Id: Ic4ccab9d344b30b72fca1503827eec1c628fa4ac --- .../latin/makedict/BinaryDictDecoder.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoder.java index 767f4fc72..f09a9b941 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoder.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoder.java @@ -430,12 +430,6 @@ public final class BinaryDictDecoder { } } - // The word cache here is a stopgap bandaid to help the catastrophic performance - // of this method. Since it performs direct, unbuffered random access to the file and - // may be called hundreds of thousands of times, the resulting performance is not - // reasonable without some kind of cache. Thus: - private static TreeMap wordCache = - new TreeMap(); /** * Finds, as a string, the word at the address passed as an argument. * @@ -448,9 +442,6 @@ public final class BinaryDictDecoder { /* package for tests */ static WeightedString getWordAtAddress( final FusionDictionaryBufferInterface buffer, final int headerSize, final int address, final FormatOptions formatOptions) { - final WeightedString cachedString = wordCache.get(address); - if (null != cachedString) return cachedString; - final WeightedString result; final int originalPointer = buffer.position(); buffer.position(address); @@ -462,7 +453,6 @@ public final class BinaryDictDecoder { formatOptions); } - wordCache.put(address, result); buffer.position(originalPointer); return result; } @@ -720,8 +710,6 @@ public final class BinaryDictDecoder { public static FusionDictionary readDictionaryBinary(final BinaryDictReader reader, final FusionDictionary dict) throws FileNotFoundException, IOException, UnsupportedFormatException { - // clear cache - wordCache.clear(); // if the buffer has not been opened, open the buffer with bytebuffer. if (reader.getBuffer() == null) reader.openBuffer(