From 88688197cd902ab23e63eae80e87c003fe9cdec8 Mon Sep 17 00:00:00 2001 From: "tomasz.kowalczewski" Date: Sun, 13 Jun 2021 23:11:31 +0200 Subject: [PATCH] Re #48: Rewrote to not use Java 9 method. --- .../java/pl/tkowalcz/tjahzi/LabelSerializer.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/pl/tkowalcz/tjahzi/LabelSerializer.java b/core/src/main/java/pl/tkowalcz/tjahzi/LabelSerializer.java index dcdd88c..226fb07 100644 --- a/core/src/main/java/pl/tkowalcz/tjahzi/LabelSerializer.java +++ b/core/src/main/java/pl/tkowalcz/tjahzi/LabelSerializer.java @@ -3,8 +3,6 @@ package pl.tkowalcz.tjahzi; import org.agrona.DirectBuffer; import org.agrona.ExpandableArrayBuffer; -import java.util.Arrays; - public class LabelSerializer { private final ExpandableArrayBuffer buffer = new ExpandableArrayBuffer(); @@ -45,11 +43,20 @@ public class LabelSerializer { if (o instanceof LabelSerializer) { LabelSerializer that = (LabelSerializer) o; + if (this.cursor != that.cursor) { + return false; + } + byte[] thisArray = this.buffer.byteArray(); byte[] thatArray = that.buffer.byteArray(); - return this.cursor == that.cursor && - Arrays.equals(thisArray, 0, cursor, thatArray, 0, cursor); + for (int i = 0; i < cursor; i++) { + if (thisArray[i] != thatArray[i]) { + return false; + } + } + + return true; } return false;