MCPcopy
hub / github.com/syncthing/syncthing / shouldCompressMessage

Method shouldCompressMessage

lib/protocol/protocol.go:919–936  ·  view source on GitHub ↗
(msg proto.Message)

Source from the content-addressed store, hash-verified

917}
918
919func (c *rawConnection) shouldCompressMessage(msg proto.Message) bool {
920 switch c.compression {
921 case CompressionNever:
922 return false
923
924 case CompressionAlways:
925 // Use compression for large enough messages
926 return proto.Size(msg) >= compressionThreshold
927
928 case CompressionMetadata:
929 _, isResponse := msg.(*bep.Response)
930 // Compress if it's large enough and not a response message
931 return !isResponse && proto.Size(msg) >= compressionThreshold
932
933 default:
934 panic("unknown compression setting")
935 }
936}
937
938// Close is called when the connection is regularly closed and thus the Close
939// BEP message is sent before terminating the actual connection. The error

Callers 1

writeMessageMethod · 0.95

Calls 1

SizeMethod · 0.65

Tested by

no test coverage detected