forked from quic-go/quic-go
ParseOtherFrames-16 148ns ± 4% 150ns ± 3% ~ (p=0.223 n=8+8) ParseAckFrame-16 302ns ± 2% 298ns ± 3% ~ (p=0.246 n=8+8) ParseStreamFrame-16 262ns ± 3% 213ns ± 2% -18.61% (p=0.000 n=8+8) ParseDatagramFrame-16 561ns ± 5% 547ns ± 4% ~ (p=0.105 n=8+8)
34 lines
906 B
Go
34 lines
906 B
Go
package ackhandler
|
|
|
|
import "github.com/quic-go/quic-go/internal/wire"
|
|
|
|
// IsFrameTypeAckEliciting returns true if the frame is ack-eliciting.
|
|
func IsFrameTypeAckEliciting(t wire.FrameType) bool {
|
|
//nolint:exhaustive // The default case catches the rest.
|
|
switch t {
|
|
case wire.FrameTypeAck, wire.FrameTypeAckECN:
|
|
return false
|
|
case wire.FrameTypeConnectionClose, wire.FrameTypeApplicationClose:
|
|
return false
|
|
default:
|
|
return true
|
|
}
|
|
}
|
|
|
|
// IsFrameAckEliciting returns true if the frame is ack-eliciting.
|
|
func IsFrameAckEliciting(f wire.Frame) bool {
|
|
_, isAck := f.(*wire.AckFrame)
|
|
_, isConnectionClose := f.(*wire.ConnectionCloseFrame)
|
|
return !isAck && !isConnectionClose
|
|
}
|
|
|
|
// HasAckElicitingFrames returns true if at least one frame is ack-eliciting.
|
|
func HasAckElicitingFrames(fs []Frame) bool {
|
|
for _, f := range fs {
|
|
if IsFrameAckEliciting(f.Frame) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|