mirror of https://github.com/go-redis/redis.git
Micro-optimize loop.
This commit is contained in:
parent
583e901221
commit
5e2cce4853
12
multi.go
12
multi.go
|
@ -82,14 +82,11 @@ func (c *MultiClient) ExecReqs(reqs []Req, conn *Conn) error {
|
||||||
|
|
||||||
statusReq := NewStatusReq()
|
statusReq := NewStatusReq()
|
||||||
|
|
||||||
// Parse MULTI command reply.
|
// Omit last request (EXEC).
|
||||||
_, err = statusReq.ParseReply(conn.Rd)
|
reqsLen := len(reqs) - 1
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse queued replies.
|
// Parse queued replies.
|
||||||
for i := 1; i < len(reqs)-1; i++ {
|
for i := 0; i < reqsLen; i++ {
|
||||||
_, err = statusReq.ParseReply(conn.Rd)
|
_, err = statusReq.ParseReply(conn.Rd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -109,7 +106,8 @@ func (c *MultiClient) ExecReqs(reqs []Req, conn *Conn) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse replies.
|
// Parse replies.
|
||||||
for i := 1; i < len(reqs)-1; i++ {
|
// Loop starts from 1 to omit first request (MULTI).
|
||||||
|
for i := 1; i < reqsLen; i++ {
|
||||||
req := reqs[i]
|
req := reqs[i]
|
||||||
val, err := req.ParseReply(conn.Rd)
|
val, err := req.ParseReply(conn.Rd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -67,7 +67,8 @@ func (c *PipelineClient) RunReqs(reqs []Req, conn *Conn) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(reqs); i++ {
|
reqsLen := len(reqs)
|
||||||
|
for i := 0; i < reqsLen; i++ {
|
||||||
req := reqs[i]
|
req := reqs[i]
|
||||||
val, err := req.ParseReply(conn.Rd)
|
val, err := req.ParseReply(conn.Rd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue