From f09ac2df441acbf6f6d6470092b9216e73218f02 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Sat, 8 Sep 2012 22:16:00 +0400 Subject: [PATCH] proper fix for handling identical keys --- .../com/intellij/util/io/PersistentEnumeratorBase.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java b/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java index 4e5ca61bd27c..cf884f9e6691 100644 --- a/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java +++ b/platform/util/src/com/intellij/util/io/PersistentEnumeratorBase.java @@ -29,6 +29,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; import java.io.*; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -372,12 +373,8 @@ abstract class PersistentEnumeratorBase implements Forceable, Closeable { protected boolean isKeyAtIndex(final Data value, final int idx) throws IOException { if (myKeyStorage == null) return false; - /* - // todo: this optimization violates the contract specified by the API of the storage: all keys must be comparable using KeyDescriptor - // todo: to be made optional and configurable from the API, until then commented. - // check if previous serialized state is the same as for value - // this is much faster than myDataDescriptor.isEqualTo(valueOf(idx), value) + // this is much faster than myDataDescriptor.isEqualTo(valueOf(idx), value) for identical objects final boolean sameValue[] = new boolean[1]; // TODO: key storage lock final int addr = indexToAddr(idx); OutputStream comparer; @@ -429,8 +426,7 @@ abstract class PersistentEnumeratorBase implements Forceable, Closeable { myDataDescriptor.save(out, value); comparer.close(); - return sameValue[0]; - */ + if (sameValue[0]) return true; return myDataDescriptor.isEqual(valueOf(idx), value); }