You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This ends up dropping into the very complex mutating func _set<S: Sequence>(bytes: S, at index: _Index) -> _Capacity where S.Element == UInt8, which is a very complex method that potentially performs multiple resizings and many bounds checks.
This is all unnecessary, as ByteBufferView is backed by a ByteBuffer. This means that we can instead call write(buffer:) with the appropriate details, and use the fast-path that that method uses to treat the collection as a ContiguousCollection.
Note that we don't need to (or want to) actually conform the ByteBufferView to ContiguousCollection. Instead we just want the same magic we've done with ByteBuffer to apply here: take our special knowledge of the layout of this type and use it to obtain a performance improvement.
The text was updated successfully, but these errors were encountered:
Currently if you want to write a
ByteBufferView
to aByteBuffer
, it will fall into this method:This ends up dropping into the very complex
mutating func _set<S: Sequence>(bytes: S, at index: _Index) -> _Capacity where S.Element == UInt8
, which is a very complex method that potentially performs multiple resizings and many bounds checks.This is all unnecessary, as
ByteBufferView
is backed by aByteBuffer
. This means that we can instead callwrite(buffer:)
with the appropriate details, and use the fast-path that that method uses to treat the collection as aContiguousCollection
.Note that we don't need to (or want to) actually conform the
ByteBufferView
toContiguousCollection
. Instead we just want the same magic we've done withByteBuffer
to apply here: take our special knowledge of the layout of this type and use it to obtain a performance improvement.The text was updated successfully, but these errors were encountered: