mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 19:40:37 +00:00
Set Capacity for Slices (#4540)
* set capacities * make it more accurate * resolve it
This commit is contained in:
parent
d2d4e7e35d
commit
0bee1de486
@ -396,7 +396,11 @@ func fetchBlockRootsBySlotRange(
|
||||
return k != nil && bytes.Compare(k, max) <= 0
|
||||
}
|
||||
}
|
||||
roots := make([][]byte, 0)
|
||||
rootsRange := (endSlot - startSlot) / step
|
||||
if endSlot < startSlot {
|
||||
rootsRange = 0
|
||||
}
|
||||
roots := make([][]byte, 0, rootsRange)
|
||||
c := bkt.Cursor()
|
||||
for k, v := c.Seek(min); conditional(k, max); k, v = c.Next() {
|
||||
if step > 1 {
|
||||
@ -409,7 +413,8 @@ func fetchBlockRootsBySlotRange(
|
||||
continue
|
||||
}
|
||||
}
|
||||
splitRoots := make([][]byte, 0)
|
||||
numOfRoots := len(v) / 32
|
||||
splitRoots := make([][]byte, 0, numOfRoots)
|
||||
for i := 0; i < len(v); i += 32 {
|
||||
splitRoots = append(splitRoots, v[i:i+32])
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user