diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h index f2cc8d623f..f86a709831 100644 --- a/AK/ByteBuffer.h +++ b/AK/ByteBuffer.h @@ -155,6 +155,17 @@ public: m_impl->trim(size); } + ByteBuffer slice_view(int offset, int size) const + { + if (is_null()) + return {}; + if (offset >= this->size()) + return {}; + if (offset + size >= this->size()) + size = this->size() - offset; + return wrap(offset_pointer(offset), size); + } + ByteBuffer slice(int offset, int size) const { if (is_null())