Add from and to (1.1.22)

This commit is contained in:
Andrea Cavalli 2025-01-23 00:44:30 +01:00
parent 75a9b68ac4
commit 53de22087f
2 changed files with 30 additions and 0 deletions

View File

@ -94,6 +94,16 @@ public interface Buf extends ByteList, RandomAccess {
*/
int getBackingByteArrayLength();
/**
* Unsafe operation, same as Offset
*/
int getBackingByteArrayFrom();
/**
* Unsafe operation, same as offset + length
*/
int getBackingByteArrayTo();
/**
* Get this element as an array with equal or bigger size, only if it's already an array, otherwise return null
* The returned array may be bigger than expected!

View File

@ -180,6 +180,16 @@ class ByteListBuf extends ByteArrayList implements Buf {
return this.size;
}
@Override
public int getBackingByteArrayFrom() {
return 0;
}
@Override
public int getBackingByteArrayTo() {
return this.size;
}
@Override
public byte @Nullable [] asUnboundedArrayStrict() {
return a;
@ -417,6 +427,16 @@ class ByteListBuf extends ByteArrayList implements Buf {
return this.to - this.from;
}
@Override
public int getBackingByteArrayFrom() {
return this.from;
}
@Override
public int getBackingByteArrayTo() {
return this.to;
}
@Override
public boolean isMutable() {
return ByteListBuf.this.isMutable();