From 6279d6b5562d5a1a67c5b8debce8d68d358b8c2b Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Tue, 13 Jul 2021 11:56:21 -0400 Subject: [PATCH] optimize hasOutstandingCryptoPackets in sentPacketHandler --- internal/ackhandler/sent_packet_handler.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/ackhandler/sent_packet_handler.go b/internal/ackhandler/sent_packet_handler.go index dd8988f0f..b9376136f 100644 --- a/internal/ackhandler/sent_packet_handler.go +++ b/internal/ackhandler/sent_packet_handler.go @@ -483,14 +483,13 @@ func (h *sentPacketHandler) getPTOTimeAndSpace() (pto time.Time, encLevel protoc } func (h *sentPacketHandler) hasOutstandingCryptoPackets() bool { - var hasInitial, hasHandshake bool - if h.initialPackets != nil { - hasInitial = h.initialPackets.history.HasOutstandingPackets() + if h.initialPackets != nil && h.initialPackets.history.HasOutstandingPackets() { + return true } - if h.handshakePackets != nil { - hasHandshake = h.handshakePackets.history.HasOutstandingPackets() + if h.handshakePackets != nil && h.handshakePackets.history.HasOutstandingPackets() { + return true } - return hasInitial || hasHandshake + return false } func (h *sentPacketHandler) hasOutstandingPackets() bool {