mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-02 04:58:38 +00:00
core/filtermaps: adjust slice preallocation capacity handling
This commit is contained in:
parent
54e9cc8957
commit
20fe4a9059
1 changed files with 6 additions and 1 deletions
|
|
@ -426,7 +426,12 @@ func (r *mapRenderer) writeFinishedMaps(pauseCb func() bool) error {
|
||||||
}
|
}
|
||||||
// add or update filter rows
|
// add or update filter rows
|
||||||
for rowIndex := uint32(0); rowIndex < r.f.mapHeight; rowIndex++ {
|
for rowIndex := uint32(0); rowIndex < r.f.mapHeight; rowIndex++ {
|
||||||
capacity := len(r.finishedMaps)
|
base := len(r.finishedMaps)
|
||||||
|
extra := 0
|
||||||
|
if newRange.maps.AfterLast() == r.finished.AfterLast() {
|
||||||
|
extra = int(oldRange.maps.AfterLast() - r.finished.AfterLast())
|
||||||
|
}
|
||||||
|
capacity := base + extra
|
||||||
|
|
||||||
mapIndices := make([]uint32, 0, capacity)
|
mapIndices := make([]uint32, 0, capacity)
|
||||||
rows := make([]FilterRow, 0, capacity)
|
rows := make([]FilterRow, 0, capacity)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue