mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-14 18:30:02 +08:00
perf: pre-allocate all known length arrays to avoid re-scaling (#5029)
Co-authored-by: Kevin Wan <wanjunfeng@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a2b98dbcf7
commit
130e1ba963
@@ -1944,7 +1944,7 @@ func (s *Redis) ZaddsCtx(ctx context.Context, key string, ps ...Pair) (int64, er
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var zs []red.Z
|
||||
zs := make([]red.Z, 0, len(ps))
|
||||
for _, p := range ps {
|
||||
z := red.Z{Score: float64(p.Score), Member: p.Key}
|
||||
zs = append(zs, z)
|
||||
|
||||
Reference in New Issue
Block a user