Skip to content

Commit 9073576

Browse files
committed
[span] formulate Span.withUnsafeBytes() better
1 parent 2b916a1 commit 9073576

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

stdlib/public/core/Span/Span.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,9 @@ extension Span where Element: BitwiseCopyable {
703703
public func withUnsafeBytes<E: Error, Result: ~Copyable>(
704704
_ body: (_ buffer: UnsafeRawBufferPointer) throws(E) -> Result
705705
) throws(E) -> Result {
706-
try RawSpan(_elements: self).withUnsafeBytes(body)
706+
try body(
707+
.init(start: _pointer, count: _count * MemoryLayout<Element>.stride)
708+
)
707709
}
708710
}
709711

0 commit comments

Comments
 (0)