eth/downloader: optimize fetch result concatenation

This commit is contained in:
rizkyikiw42 2025-12-02 17:05:38 +08:00
parent da3822dcec
commit 7d0be24267

View file

@ -940,7 +940,11 @@ func (d *Downloader) processSnapSyncContent() error {
} }
} }
} else { // results already piled up, consume before handling pivot move } else { // results already piled up, consume before handling pivot move
results = append(append([]*fetchResult{oldPivot}, oldTail...), results...) newResults := make([]*fetchResult, 1+len(oldTail)+len(results))
newResults[0] = oldPivot
copy(newResults[1:], oldTail)
copy(newResults[1+len(oldTail):], results)
results = newResults
} }
// Split around the pivot block and process the two sides via snap/full sync // Split around the pivot block and process the two sides via snap/full sync
if !d.committed.Load() { if !d.committed.Load() {