From 233330d01525f2a7ca5fc8a46aae984a1db92a63 Mon Sep 17 00:00:00 2001 From: Per Minborg Date: Thu, 24 Mar 2022 11:27:49 +0100 Subject: [PATCH] Remove deprecated methods, Fix #11 --- .../openhft/chronicle/algo/bytes/Access.java | 60 ++++++++++++++++--- .../chronicle/algo/bytes/ReadAccess.java | 26 -------- .../chronicle/algo/bytes/WriteAccess.java | 25 -------- 3 files changed, 52 insertions(+), 59 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/algo/bytes/Access.java b/src/main/java/net/openhft/chronicle/algo/bytes/Access.java index fbe1bea4..92da7df1 100644 --- a/src/main/java/net/openhft/chronicle/algo/bytes/Access.java +++ b/src/main/java/net/openhft/chronicle/algo/bytes/Access.java @@ -39,16 +39,60 @@ static ReadAccess checkedRandomDataInputAccess() { return BytesAccesses.RandomDataInputReadAccessEnum.INSTANCE; } - static void copy(ReadAccess sourceAccess, S source, long sourceOffset, - WriteAccess targetAccess, T target, long targetOffset, - long len) { - targetAccess.writeFrom(target, targetOffset, sourceAccess, source, sourceOffset, len); + static void copy(final ReadAccess sourceAccess, + final S source, + final long sourceOffset, + final WriteAccess targetAccess, + final T target, + final long targetOffset, + final long len) { + if (targetAccess == sourceAccess && target == source && targetOffset == sourceOffset) + return; + long i = 0; + while (len - i >= 8L) { + targetAccess.writeLong(target, targetOffset + i, sourceAccess.readLong(source, sourceOffset + i)); + i += 8L; + } + if (len - i >= 4L) { + targetAccess.writeInt(target, targetOffset + i, sourceAccess.readInt(source, sourceOffset + i)); + i += 4L; + } + if (len - i >= 2L) { + targetAccess.writeShort(target, targetOffset + i, sourceAccess.readShort(source, sourceOffset + i)); + i += 2L; + } + if (i < len) { + targetAccess.writeByte(target, targetOffset + i, sourceAccess.readByte(source, sourceOffset + i)); + } } - static boolean equivalent(ReadAccess access1, T handle1, long offset1, - ReadAccess access2, U handle2, long offset2, - long len) { - return access1.compareTo(handle1, offset1, access2, handle2, offset2, len); + static boolean equivalent(final ReadAccess access1, + final T handle1, + final long offset1, + final ReadAccess access2, + final U handle2, + final long offset2, + final long len) { + long i = 0; + while (len - i >= 8L) { + if (access1.readLong(handle1, offset1 + i) != access2.readLong(handle2, offset2 + i)) + return false; + i += 8L; + } + if (len - i >= 4L) { + if (access1.readInt(handle1, offset1 + i) != access2.readInt(handle2, offset2 + i)) + return false; + i += 4L; + } + if (len - i >= 2L) { + if (access1.readShort(handle1, offset1 + i) != access2.readShort(handle2, offset2 + i)) + return false; + i += 2L; + } + if (i < len) { + return access1.readByte(handle1, offset1 + i) == access2.readByte(handle2, offset2 + i); + } + return true; } /** diff --git a/src/main/java/net/openhft/chronicle/algo/bytes/ReadAccess.java b/src/main/java/net/openhft/chronicle/algo/bytes/ReadAccess.java index 718322d0..07dbc9c1 100644 --- a/src/main/java/net/openhft/chronicle/algo/bytes/ReadAccess.java +++ b/src/main/java/net/openhft/chronicle/algo/bytes/ReadAccess.java @@ -88,30 +88,4 @@ default long readVolatileLong(T handle, long offset) { throw new UnsupportedOperationException(); } - /** - * @deprecated use {@link Access#equivalent} instead - */ - default boolean compareTo( - T handle, long offset, ReadAccess sourceAccess, S source, long sourceOffset, - long len) { - long i = 0; - while (len - i >= 8L) { - if (readLong(handle, offset + i) != sourceAccess.readLong(source, sourceOffset + i)) - return false; - i += 8L; - } - if (len - i >= 4L) { - if (readInt(handle, offset + i) != sourceAccess.readInt(source, sourceOffset + i)) - return false; - i += 4L; - } - if (len - i >= 2L) { - if (readShort(handle, offset + i) != sourceAccess.readShort(source, sourceOffset + i)) - return false; - i += 2L; - } - if (i < len) - return readByte(handle, offset + i) == sourceAccess.readByte(source, sourceOffset + i); - return true; - } } diff --git a/src/main/java/net/openhft/chronicle/algo/bytes/WriteAccess.java b/src/main/java/net/openhft/chronicle/algo/bytes/WriteAccess.java index 3f40a582..0188496e 100644 --- a/src/main/java/net/openhft/chronicle/algo/bytes/WriteAccess.java +++ b/src/main/java/net/openhft/chronicle/algo/bytes/WriteAccess.java @@ -69,31 +69,6 @@ default void writeOrderedLong(T handle, long offset, long i) { void writeDouble(T handle, long offset, double d); - /** - * @deprecated use {@link Access#copy} instead - */ - default void writeFrom( - T handle, long offset, - ReadAccess sourceAccess, S source, long sourceOffset, long len) { - if (this == sourceAccess && handle == source && offset == sourceOffset) - return; - long i = 0; - while (len - i >= 8L) { - writeLong(handle, offset + i, sourceAccess.readLong(source, sourceOffset + i)); - i += 8L; - } - if (len - i >= 4L) { - writeInt(handle, offset + i, sourceAccess.readInt(source, sourceOffset + i)); - i += 4L; - } - if (len - i >= 2L) { - writeShort(handle, offset + i, sourceAccess.readShort(source, sourceOffset + i)); - i += 2L; - } - if (i < len) - writeByte(handle, offset + i, sourceAccess.readByte(source, sourceOffset + i)); - } - default void writeBytes(T handle, long offset, long len, byte b) { char c; int i;