mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-27 05:04:23 +00:00
Remove a few unnecessary allocations. (#243)
Motivation: Unnecessary allocations are bad! Modifications: - Use 'removeAll' instead of allocating a new buffer when dropping pending reads in the 'HTTP2StreamChannel' - Use a static empty buffer in 'DataBuffer.evacuatePendingWrites' Result: - Fewer allocations. - Resolves #240 - Resolves #241
This commit is contained in:
1 parent
860a6e77c8
commit
cee48fd87d
2 files changed
+6
-3
No files matched your search
@@ -649,8 +649,8 @@ final class HTTP2StreamChannel: Channel, ChannelCore {
|
||||
private extension HTTP2StreamChannel {
|
||||
/// Drop all pending reads.
|
||||
private func dropPendingReads() {
|
||||
/// To drop all the reads, as we don't need to report it, we just allocate a new buffer of 0 size.
|
||||
self.pendingReads = CircularBuffer(initialCapacity: 0)
|
||||
/// We don't need to report the dropped reads, just remove them all.
|
||||
self.pendingReads.removeAll()
|
||||
}
|
||||
|
||||
/// Deliver all pending reads to the channel.
|
||||
|
||||
Reference in new issue
Block a user