mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth/fetcher: using slices.Clone to simplify codes
This commit is contained in:
parent
a3829178af
commit
b2e2fd067f
1 changed files with 3 additions and 4 deletions
|
|
@ -22,6 +22,7 @@ import (
|
|||
"fmt"
|
||||
"math"
|
||||
mrand "math/rand"
|
||||
"slices"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
|
|
@ -973,8 +974,7 @@ func (f *TxFetcher) forEachAnnounce(announces map[common.Hash]*txMetadata, do fu
|
|||
// rotateStrings rotates the contents of a slice by n steps. This method is only
|
||||
// used in tests to simulate random map iteration but keep it deterministic.
|
||||
func rotateStrings(slice []string, n int) {
|
||||
orig := make([]string, len(slice))
|
||||
copy(orig, slice)
|
||||
orig := slices.Clone(slice)
|
||||
|
||||
for i := 0; i < len(orig); i++ {
|
||||
slice[i] = orig[(i+n)%len(orig)]
|
||||
|
|
@ -996,8 +996,7 @@ func sortHashes(slice []common.Hash) {
|
|||
// rotateHashes rotates the contents of a slice by n steps. This method is only
|
||||
// used in tests to simulate random map iteration but keep it deterministic.
|
||||
func rotateHashes(slice []common.Hash, n int) {
|
||||
orig := make([]common.Hash, len(slice))
|
||||
copy(orig, slice)
|
||||
orig := slices.Clone(slice)
|
||||
|
||||
for i := 0; i < len(orig); i++ {
|
||||
slice[i] = orig[(i+n)%len(orig)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue