all: substitute zeroTime with time.Time{}, since this generates more optimal binary code

This commit is contained in:
Aliaksandr Valialkin 2022-02-07 14:36:41 +02:00
parent 5aee6eb406
commit 34d14c4940
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
2 changed files with 3 additions and 7 deletions

View file

@ -462,8 +462,6 @@ func (ctx *vmselectRequestCtx) writeUint64(n uint64) error {
const maxRPCNameSize = 128
var zeroTime time.Time
func (s *Server) processVMSelectRequest(ctx *vmselectRequestCtx) error {
// Read rpcName
// Do not set deadline on reading rpcName, since it may take a
@ -482,7 +480,7 @@ func (s *Server) processVMSelectRequest(ctx *vmselectRequestCtx) error {
return fmt.Errorf("cannot set read deadline for reading request args: %w", err)
}
defer func() {
_ = ctx.bc.SetReadDeadline(zeroTime)
_ = ctx.bc.SetReadDeadline(time.Time{})
}()
// Read the timeout for request execution.

View file

@ -132,7 +132,7 @@ func writeMessage(c net.Conn, msg string) error {
return fmt.Errorf("cannot flush %q to server: %w", msg, err)
}
}
if err := c.SetWriteDeadline(zeroTime); err != nil {
if err := c.SetWriteDeadline(time.Time{}); err != nil {
return fmt.Errorf("cannot reset write deadline: %w", err)
}
return nil
@ -161,10 +161,8 @@ func readData(c net.Conn, dataLen int) ([]byte, error) {
if n, err := io.ReadFull(c, data); err != nil {
return nil, fmt.Errorf("cannot read message with size %d: %w; read only %d bytes", dataLen, err, n)
}
if err := c.SetReadDeadline(zeroTime); err != nil {
if err := c.SetReadDeadline(time.Time{}); err != nil {
return nil, fmt.Errorf("cannot reset read deadline: %w", err)
}
return data, nil
}
var zeroTime time.Time