readSubSource

open fun readSubSource(nBytes: Int): Source<*>(source)

Reads the next nBytes bytes and returns them as an independent Source, advancing past them.

Unlike readByteArray, this never obliges a copy: array-backed sources (e.g. ByteArrayBuffer) return a view sharing their backing array in O(1). The default implementation falls back to a single copy for sources that cannot share storage (e.g. streams). The returned source is independent of this source's read position and lifetime, so it may be retained and re-read (via peek) afterwards.

This is what keeps OCTET STRING decapsulation O(input) instead of O(input²): each nested layer is re-parsed from a shared view rather than a fresh per-layer copy of the remaining content.