Data can encapsulate it’s own sub-sequence type by housing a range of the slice in the structural type for Data. By doing this it avoids the API explosion of supporting all APIs that take Data would need overloads to take a slice of Data. This does come at a small conceptual cost: any index based iteration should always account for the startIndex and endIndex of the Data (which was an implicit requirement previously by being a Collection). Moreover this prevents the requirement of O(n) copies of Data if it is never mutated while parsing sub sequences; so more than an API amelioration this also could offer a more effecient code-path for applications to use.
This iterator uses an inline 32-byte buffer so it doesn't have to call
copyBytes(to:count:) for every single byte. It results in an approximate
6x speedup on my computer.
This iterator uses an inline 32-byte buffer so it doesn't have to call
copyBytes(to:count:) for every single byte. It results in an approximate
6x speedup on my computer.