From 806efd6d6e1b58bf6818510bc893cf27f5a0e4a6 Mon Sep 17 00:00:00 2001 From: Peter Lawrey Date: Fri, 14 Sep 2018 15:16:20 +0100 Subject: [PATCH] Include the size of the checksum in the entry size. --- .../map/impl/stage/entry/MapEntryStages.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/impl/stage/entry/MapEntryStages.java b/src/main/java/net/openhft/chronicle/map/impl/stage/entry/MapEntryStages.java index 7cf378b91..36cd80a95 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/stage/entry/MapEntryStages.java +++ b/src/main/java/net/openhft/chronicle/map/impl/stage/entry/MapEntryStages.java @@ -224,21 +224,16 @@ public abstract class MapEntryStages extends HashEntryStages } public long innerEntrySize(long sizeOfEverythingBeforeValue, long valueSize) { - long sizeWithoutChecksum; - if (mh.m().constantlySizedEntry) { - sizeWithoutChecksum = - alignAddr(sizeOfEverythingBeforeValue + valueSize, mh.m().alignment); - } else if (mh.m().couldNotDetermineAlignmentBeforeAllocation) { - sizeWithoutChecksum = sizeOfEverythingBeforeValue + mh.m().worstAlignment + valueSize; - } else { - sizeWithoutChecksum = - alignAddr(sizeOfEverythingBeforeValue, mh.m().alignment) + valueSize; - } - return sizeWithoutChecksum + checksumStrategy.extraEntryBytes(); + if (!mh.m().constantlySizedEntry && mh.m().couldNotDetermineAlignmentBeforeAllocation) + sizeOfEverythingBeforeValue += mh.m().worstAlignment; + int alignment = mh.m().alignment; + return alignAddr(sizeOfEverythingBeforeValue, alignment) + + alignAddr(valueSize, alignment); } long sizeOfEverythingBeforeValue(long keySize, long valueSize) { return mh.m().keySizeMarshaller.storingLength(keySize) + keySize + + checksumStrategy.extraEntryBytes() + mh.m().valueSizeMarshaller.storingLength(valueSize); }