Skip to content

Commit c22eefb

Browse files
authored
Merge pull request #39 from glbrntt/zero-init
Avoid allocating in FrameArray empty init
2 parents 60afc2e + 206b7c7 commit c22eefb

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

Sources/SwiftNetwork/Protocols/FrameArray.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public struct FrameArray: ~Copyable {
3636
}
3737

3838
public init() {
39-
self.frames = NetworkUniqueDeque<Frame>(minimumCapacity: 1)
39+
self.frames = NetworkUniqueDeque<Frame>()
4040
}
4141

4242
public init(capacity: Int) {

Sources/SwiftNetwork/QUIC/QUICConnection.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3196,11 +3196,14 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol,
31963196
else {
31973197
return false
31983198
}
3199-
var datagramBatch = FrameArray()
3199+
3200+
var datagramBatch: FrameArray
32003201
if self.flowControlState.pendingOutboundBytesToSend > 0 && availableCongestionWindow > 0 {
32013202
datagramBatch = buildOutboundFrameBatch(
32023203
availableCongestionWindow: (availableCongestionWindow - totalSendBytes)
32033204
)
3205+
} else {
3206+
datagramBatch = FrameArray()
32043207
}
32053208

32063209
// Sending on the current path.

0 commit comments

Comments
 (0)