Remove unused array (#2361)

Motivation:

The `PendingDatagramWritesManager` unconditionally creates an array and
reserves capacity... only to never use it.

Modifications:

Remove the unsued code.

Result:

Fewer allocations.
This commit is contained in:
George Barnett 2023-02-03 09:25:14 +00:00 committed by GitHub
parent 45167b8006
commit 0d6137f250
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 4 deletions

View File

@ -263,9 +263,6 @@ private struct PendingDatagramWritesState {
/// - returns: A closure that the caller _needs_ to run which will fulfill the promises of the writes, and a `WriteResult` that indicates if we could write /// - returns: A closure that the caller _needs_ to run which will fulfill the promises of the writes, and a `WriteResult` that indicates if we could write
/// everything or not. /// everything or not.
private mutating func didVectorWrite(written: Int, messages: UnsafeMutableBufferPointer<MMsgHdr>) -> (DatagramWritePromiseFiller?, OneWriteOperationResult) { private mutating func didVectorWrite(written: Int, messages: UnsafeMutableBufferPointer<MMsgHdr>) -> (DatagramWritePromiseFiller?, OneWriteOperationResult) {
var fillers: [DatagramWritePromiseFiller] = []
fillers.reserveCapacity(written)
// This was a vector write. We wrote `written` number of messages. // This was a vector write. We wrote `written` number of messages.
let writes = messages[messages.startIndex...messages.index(messages.startIndex, offsetBy: written - 1)] let writes = messages[messages.startIndex...messages.index(messages.startIndex, offsetBy: written - 1)]
var promiseFiller: DatagramWritePromiseFiller? var promiseFiller: DatagramWritePromiseFiller?
@ -394,7 +391,7 @@ final class PendingDatagramWritesManager: PendingWritesManager {
/// Storage for sockaddr structures. Only present on Linux because Darwin does not support gathering /// Storage for sockaddr structures. Only present on Linux because Darwin does not support gathering
/// writes. /// writes.
private var addresses: UnsafeMutableBufferPointer<sockaddr_storage> private var addresses: UnsafeMutableBufferPointer<sockaddr_storage>
private var controlMessageStorage: UnsafeControlMessageStorage private var controlMessageStorage: UnsafeControlMessageStorage
private var state = PendingDatagramWritesState() private var state = PendingDatagramWritesState()