use a default initial maximum range count

This commit is contained in:
siddontang 2015-05-12 08:52:27 +08:00
parent eee7468b85
commit 1df83b61b4
1 changed files with 4 additions and 3 deletions

View File

@ -583,9 +583,10 @@ func (db *DB) zRange(key []byte, min int64, max int64, offset int, count int, re
return []ScorePair{}, nil return []ScorePair{}, nil
} }
nv := 64 nv := count
if count > 0 { // count may be very large, so we must limit it for below mem make.
nv = count if nv <= 0 || nv > 1024 {
nv = 64
} }
v := make([]ScorePair, 0, nv) v := make([]ScorePair, 0, nv)