1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Reuse buffer for constructing request.

This commit is contained in:
Vladimir Mihailenco
2012-08-14 18:20:22 +03:00
parent 625adac9ab
commit a2f5423658
8 changed files with 32 additions and 44 deletions

View File

@ -46,17 +46,7 @@ func (c *PipelineClient) RunQueued() ([]Req, error) {
}
func (c *PipelineClient) RunReqs(reqs []Req, conn *Conn) error {
var multiReq []byte
if len(reqs) == 1 {
multiReq = reqs[0].Req()
} else {
multiReq = make([]byte, 0, 1024)
for _, req := range reqs {
multiReq = append(multiReq, req.Req()...)
}
}
err := c.WriteReq(multiReq, conn)
err := c.WriteReq(conn, reqs...)
if err != nil {
return err
}