public int compareTo(final DirectBuffer that) { final int thisCapacity = this.capacity(); final int thatCapacity = that.capacity(); final byte[] thisByteArray = this.byteArray; final byte[] thatByteArray = that.byteArray(); final long thisOffset = this.addressOffset(); final long thatOffset = that.addressOffset(); for (int i = 0, length = Math.min(thisCapacity, thatCapacity); i < length; i++) { final int cmp = Byte.compare( UNSAFE.getByte(thisByteArray, thisOffset + i), UNSAFE.getByte(thatByteArray, thatOffset + i)); if (0 != cmp) { return cmp; } } if (thisCapacity != thatCapacity) { return thisCapacity - thatCapacity; } return 0; }
public int compareTo(final DirectBuffer that) { final int thisCapacity = this.capacity(); final int thatCapacity = that.capacity(); final byte[] thisByteArray = this.byteArray; final byte[] thatByteArray = that.byteArray(); final long thisOffset = this.addressOffset(); final long thatOffset = that.addressOffset(); for (int i = 0, length = Math.min(thisCapacity, thatCapacity); i < length; i++) { final int cmp = Byte.compare( UNSAFE.getByte(thisByteArray, thisOffset + i), UNSAFE.getByte(thatByteArray, thatOffset + i)); if (0 != cmp) { return cmp; } } if (thisCapacity != thatCapacity) { return thisCapacity - thatCapacity; } return 0; }
public int compareTo(final DirectBuffer that) { final int thisCapacity = this.capacity(); final int thatCapacity = that.capacity(); final byte[] thisByteArray = this.byteArray; final byte[] thatByteArray = that.byteArray(); final long thisOffset = this.addressOffset(); final long thatOffset = that.addressOffset(); for (int i = 0, length = Math.min(thisCapacity, thatCapacity); i < length; i++) { final int cmp = Byte.compare( UNSAFE.getByte(thisByteArray, thisOffset + i), UNSAFE.getByte(thatByteArray, thatOffset + i)); if (0 != cmp) { return cmp; } } if (thisCapacity != thatCapacity) { return thisCapacity - thatCapacity; } return 0; } }