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
Add basic RawSpan support for initializing and merging messages (#1857)
On platforms targeting Swift 6.2 and later this allows a `RawSpan` in
lieu of `SwiftProtobufContiguousBytes`-conforming type when creating or
merging a protobuf message. This will improve memory usage by reducing
allocations, for example when parsing a large document that includes
protobuf messages as part of its binary. Unlike the internal `_merge`
function, this does not expose unsafe API while retaining its benefits.
- I decided to make a twin declaration of the initializer and `merge`
function instead of conforming `RawSpan` to
`SwiftProtobufContiguousTypes`, because
- a) `RawSpan` is not mutable, and
- b) `Span` types are non-owning and cannot conform to initializers.
- I used the conditional compilation block and `@available` directive
per ~~analogy to [this implementation in
SwiftNIO](https://github.com/apple/swift-nio/blob/main/Sources/NIOCore/ByteBuffer-core.swift#L1066)~~
[docs](https://developer.apple.com/documentation/swift/rawspan).
---------
Co-authored-by: Franz Busch <f.busch@apple.com>
0 commit comments