Skip to content

Commit

Permalink
Use buffered writer for Snappy compression.
Browse files Browse the repository at this point in the history
The non-buffered writer is now deprecated. Also the amount of compression achieved and the CPU overhead is much better when using the buffered writer.
  • Loading branch information
philpearl committed Apr 12, 2024
1 parent c2c3842 commit 56633a8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ func NewConn(addr string, config *Config, delegate ConnDelegate) *Conn {
// The logger parameter is an interface that requires the following
// method to be implemented (such as the the stdlib log.Logger):
//
// Output(calldepth int, s string)
//
// Output(calldepth int, s string)
func (c *Conn) SetLogger(l logger, lvl LogLevel, format string) {
c.logGuard.Lock()
defer c.logGuard.Unlock()
Expand Down Expand Up @@ -468,7 +467,7 @@ func (c *Conn) upgradeSnappy() error {
conn = c.tlsConn
}
c.r = snappy.NewReader(conn)
c.w = snappy.NewWriter(conn)
c.w = snappy.NewBufferedWriter(conn)
frameType, data, err := ReadUnpackedResponse(c, c.config.MaxMsgSize)
if err != nil {
return err
Expand Down

0 comments on commit 56633a8

Please sign in to comment.