@@ -545,7 +545,7 @@ private extension IORing {
545545 count: Int ,
546546 link: Bool = false
547547 ) throws -> AsyncThrowingChannel < [ UInt8 ] , Error > {
548- var buffer = [ UInt8] ( repeating : 0 , count: count)
548+ var buffer = [ UInt8 ] . _unsafelyInitialized ( count: count)
549549 return try prepareAndSubmitMultishot (
550550 . recv,
551551 fd: fd,
@@ -695,7 +695,7 @@ public extension IORing {
695695 }
696696
697697 func read( count: Int , from fd: FileDescriptorRepresentable ) async throws -> [ UInt8 ] {
698- var buffer = [ UInt8] ( repeating : 0 , count: count)
698+ var buffer = [ UInt8 ] . _unsafelyInitialized ( count: count)
699699 let nread = try await read ( into: & buffer, count: count, from: fd)
700700 return Array ( buffer. prefix ( nread) )
701701 }
@@ -722,7 +722,7 @@ public extension IORing {
722722 }
723723
724724 func receive( count: Int , from fd: FileDescriptorRepresentable ) async throws -> [ UInt8 ] {
725- var buffer = [ UInt8] ( repeating : 0 , count: count)
725+ var buffer = [ UInt8 ] . _unsafelyInitialized ( count: count)
726726 try await io_uring_op_recv ( fd: fd, buffer: & buffer)
727727 return buffer
728728 }
@@ -958,3 +958,11 @@ extension IORing: Hashable {
958958 ObjectIdentifier ( self ) . hash ( into: & hasher)
959959 }
960960}
961+
962+ package extension [ UInt8 ] {
963+ static func _unsafelyInitialized( count: Int ) -> Self {
964+ Self ( unsafeUninitializedCapacity: count) { _, initializedCount in
965+ initializedCount = count
966+ }
967+ }
968+ }
0 commit comments