Skip to content

Commit 7d0be24

Browse files
committed
eth/downloader: optimize fetch result concatenation
1 parent da3822d commit 7d0be24

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

eth/downloader/downloader.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,11 @@ func (d *Downloader) processSnapSyncContent() error {
940940
}
941941
}
942942
} else { // results already piled up, consume before handling pivot move
943-
results = append(append([]*fetchResult{oldPivot}, oldTail...), results...)
943+
newResults := make([]*fetchResult, 1+len(oldTail)+len(results))
944+
newResults[0] = oldPivot
945+
copy(newResults[1:], oldTail)
946+
copy(newResults[1+len(oldTail):], results)
947+
results = newResults
944948
}
945949
// Split around the pivot block and process the two sides via snap/full sync
946950
if !d.committed.Load() {

0 commit comments

Comments
 (0)