From f487bc4ecaa11df77caf4a47868494d516f75a4f Mon Sep 17 00:00:00 2001 From: Peter Lawrey Date: Thu, 14 May 2015 12:18:47 +0100 Subject: [PATCH] Performance tune for mit. --- .../openhft/chronicle/hash/impl/VanillaChronicleHash.java | 6 +++--- .../hash/serialization/internal/CharSequenceWriter.java | 2 +- .../hash/serialization/internal/DirectBytesBuffer.java | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/hash/impl/VanillaChronicleHash.java b/src/main/java/net/openhft/chronicle/hash/impl/VanillaChronicleHash.java index ff8a2d2ec..5cb6b5c88 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/VanillaChronicleHash.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/VanillaChronicleHash.java @@ -19,18 +19,18 @@ package net.openhft.chronicle.hash.impl; import net.openhft.chronicle.hash.ChronicleHash; import net.openhft.chronicle.hash.KeyContext; import net.openhft.chronicle.hash.impl.hashlookup.HashLookup; +import net.openhft.chronicle.hash.impl.util.BuildVersion; import net.openhft.chronicle.hash.serialization.BytesReader; import net.openhft.chronicle.hash.serialization.SizeMarshaller; import net.openhft.chronicle.hash.serialization.internal.MetaBytesInterop; import net.openhft.chronicle.hash.serialization.internal.MetaProvider; import net.openhft.chronicle.hash.serialization.internal.SerializationBuilder; -import net.openhft.chronicle.hash.impl.util.BuildVersion; import net.openhft.lang.Jvm; import net.openhft.lang.io.Bytes; import net.openhft.lang.io.BytesStore; import net.openhft.lang.io.MappedStore; import net.openhft.lang.io.NativeBytes; -import net.openhft.lang.io.serialization.JDKObjectSerializer; +import net.openhft.lang.io.serialization.BytesMarshallableSerializer; import net.openhft.lang.threadlocal.Provider; import java.io.File; @@ -224,7 +224,7 @@ public abstract class VanillaChronicleHash implements BytesW @Override public long size(@NotNull CS s) { - return AbstractBytes.findUTFLength(s, s.length()); + return AbstractBytes.findUTFLength(s); } @Override diff --git a/src/main/java/net/openhft/chronicle/hash/serialization/internal/DirectBytesBuffer.java b/src/main/java/net/openhft/chronicle/hash/serialization/internal/DirectBytesBuffer.java index 8965b5c3c..a7d91daff 100644 --- a/src/main/java/net/openhft/chronicle/hash/serialization/internal/DirectBytesBuffer.java +++ b/src/main/java/net/openhft/chronicle/hash/serialization/internal/DirectBytesBuffer.java @@ -20,8 +20,9 @@ import net.openhft.chronicle.hash.serialization.BytesWriter; import net.openhft.lang.io.Bytes; import net.openhft.lang.io.DirectBytes; import net.openhft.lang.io.DirectStore; +import net.openhft.lang.io.serialization.BytesMarshallableSerializer; import net.openhft.lang.io.serialization.BytesMarshaller; -import net.openhft.lang.io.serialization.JDKObjectSerializer; +import net.openhft.lang.io.serialization.ObjectSerializer; import net.openhft.lang.threadlocal.StatefulCopyable; import java.io.IOException; @@ -37,6 +38,7 @@ class DirectBytesBuffer transient ForBytesMarshaller forBytesMarshaller; transient ForBytesWriter forBytesWriter; transient ForDataValueWriter forDataValueWriter; + private final ObjectSerializer objectSerializer = BytesMarshallableSerializer.create(); DirectBytesBuffer(Serializable identity) { this.identity = identity; @@ -65,7 +67,7 @@ class DirectBytesBuffer return buffer = store.bytes(); } } else { - buffer = new DirectStore(JDKObjectSerializer.INSTANCE, Math.max(1, maxSize), true) + buffer = new DirectStore(objectSerializer, Math.max(1, maxSize), true) .bytes(); return buffer; }