The length bytes of bytes from offset on. Nothing is copied.
The length bytes of bytes from offset on. Nothing is copied.
Fails fast with an IndexOutOfBoundsException when the range doesn't lie inside bytes (offset or length negative, or offset + length > bytes.length) — the contract of java.util.Arrays.copyOfRange, ByteBuffer.wrap and jsoniter-scala's own readFromSubArray. Offsets are the caller's arithmetic over an array it holds, not data read off the wire, so a wrong one is a bug at the call site; checking here means no optic ever runs on one.
The bytes between buf's position and its limit, as a slice. The buffer's position, limit and mark are left as they were.
The bytes between buf's position and its limit, as a slice. The buffer's position, limit and mark are left as they were.
A buffer with an accessible array (buf.hasArray: a heap buffer that isn't read-only) is '''not copied''': the slice is a view of buf.array from buf.arrayOffset + buf.position, buf.remaining bytes long, with the view's rules — don't change the bytes while it's in use, and it keeps the whole array reachable.
A '''direct''' or '''read-only''' buffer exposes no array, so its remaining bytes are '''copied once''', into an array of the slice's own.