From 7f297029195eb704fa6ec1121b716c001274cdf4 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Fri, 12 Dec 2014 12:51:26 +0000 Subject: [PATCH] HCOLL-240 removed the over use of clear() --- .../chronicle/map/StatelessChronicleMap.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java b/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java index c8e5aa824..118419002 100644 --- a/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java @@ -297,6 +297,7 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon if (LOG.isDebugEnabled()) LOG.debug("Attached to a map with a remote identifier=" + remoteIdentifier + " ,name=" + name); + } @NotNull @@ -593,7 +594,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon } public void clear() { - fetchVoid(CLEAR); } @@ -839,15 +839,8 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon private long writeEvent(@NotNull StatelessChronicleMap.EventId event) { assert outBytesLock.isHeldByCurrentThread(); assert !inBytesLock.isHeldByCurrentThread(); - - outBuffer.clear(); - outBytes.clear(); - assert event != HEARTBEAT; - outBytes.clear(); - outBuffer.clear(); - outBytes.write((byte) event.ordinal()); return markSizeLocation(); @@ -957,9 +950,8 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon writeSizeAndTransactionIdAt(sizeLocation, transactionId); // send out all the bytes - writeBytesToSocket(outBytes, timeoutTime); - outBytes.clear(); - outBytes.buffer().clear(); + writeBytesToSocket(timeoutTime); + break; } catch (@NotNull java.nio.channels.ClosedChannelException | ClosedConnectionException e) { @@ -1184,12 +1176,12 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon } - private void writeBytesToSocket(@NotNull final Bytes out, long timeoutTime) throws IOException { + private void writeBytesToSocket(long timeoutTime) throws IOException { assert outBytesLock.isHeldByCurrentThread(); assert !inBytesLock.isHeldByCurrentThread(); - outBuffer.limit((int) out.position()); + outBuffer.limit((int) outBytes.position()); outBuffer.position(0); while (outBuffer.remaining() > 0) { @@ -1197,7 +1189,6 @@ class StatelessChronicleMap implements ChronicleMap, Closeable, Clon checkTimeout(timeoutTime); } - out.clear(); outBuffer.clear(); outBytes.clear(); }