@Override public VanillaBytes<Underlying> appendUtf8(char[] chars, int offset, int length) throws BufferOverflowException, IllegalArgumentException, IORuntimeException { ensureCapacity(writePosition() + length); if (bytesStore instanceof NativeBytesStore) { writePosition( ((NativeBytesStore) bytesStore).appendUTF(writePosition(), chars, offset, length)); } else { super.appendUtf8(chars, offset, length); } return this; }
@NotNull @Override public Bytes<Underlying> write(@NotNull BytesStore bytes, long offset, long length) throws BufferOverflowException, BufferUnderflowException, IllegalArgumentException, IORuntimeException { if (bytes.bytesStore() instanceof NativeBytesStore && length >= 64) { long len = Math.min(writeRemaining(), Math.min(bytes.readRemaining(), length)); if (len > 0) { writeCheckOffset(writePosition(), len); OS.memory().copyMemory(bytes.address(offset), address(writePosition()), len); writeSkip(len); } } else { super.write(bytes, offset, length); } return this; }
@NotNull public VanillaBytes append(@NotNull CharSequence str, int start, int end) throws IndexOutOfBoundsException { try { if (bytesStore() instanceof NativeBytesStore) { if (str instanceof BytesStore) { write((BytesStore) str, (long) start, end - start); return this; } if (str instanceof String) { write(str, start, end - start); return this; } } super.append(str, start, end); return this; } catch (Exception e) { throw new IndexOutOfBoundsException(e.toString()); } }