diff options
author | Oleg Kovalov <iamolegkovalov@gmail.com> | 2018-08-07 18:56:40 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-08-07 18:56:40 +0800 |
commit | cf05ef9106779da0df62c0c03312fc489171aaa5 (patch) | |
tree | a2d5185dea85a478895b799da81e41f8e383cb52 /p2p/discover | |
parent | de9b0660acf26edc3b261b805c1a3454e3c76321 (diff) | |
download | dexon-cf05ef9106779da0df62c0c03312fc489171aaa5.tar.gz dexon-cf05ef9106779da0df62c0c03312fc489171aaa5.tar.zst dexon-cf05ef9106779da0df62c0c03312fc489171aaa5.zip |
p2p, swarm, trie: avoid copying slices in loops (#17265)
Diffstat (limited to 'p2p/discover')
-rw-r--r-- | p2p/discover/table.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/p2p/discover/table.go b/p2p/discover/table.go index 8803daa56..0a554bbeb 100644 --- a/p2p/discover/table.go +++ b/p2p/discover/table.go @@ -160,7 +160,7 @@ func (tab *Table) ReadRandomNodes(buf []*Node) (n int) { // Find all non-empty buckets and get a fresh slice of their entries. var buckets [][]*Node - for _, b := range tab.buckets { + for _, b := range &tab.buckets { if len(b.entries) > 0 { buckets = append(buckets, b.entries[:]) } @@ -508,7 +508,7 @@ func (tab *Table) copyLiveNodes() { defer tab.mutex.Unlock() now := time.Now() - for _, b := range tab.buckets { + for _, b := range &tab.buckets { for _, n := range b.entries { if now.Sub(n.addedAt) >= seedMinTableTime { tab.db.updateNode(n) @@ -524,7 +524,7 @@ func (tab *Table) closest(target common.Hash, nresults int) *nodesByDistance { // obviously correct. I believe that tree-based buckets would make // this easier to implement efficiently. close := &nodesByDistance{target: target} - for _, b := range tab.buckets { + for _, b := range &tab.buckets { for _, n := range b.entries { close.push(n, nresults) } @@ -533,7 +533,7 @@ func (tab *Table) closest(target common.Hash, nresults int) *nodesByDistance { } func (tab *Table) len() (n int) { - for _, b := range tab.buckets { + for _, b := range &tab.buckets { n += len(b.entries) } return n |