1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-06-12 22:07:47 +02:00

Preallocate nodes slice in addNodes before populating it

This commit is contained in:
Milos Gajdos
2019-07-15 14:47:33 +01:00
parent 609934ce99
commit c108188d65

View File

@ -1,12 +1,11 @@
package registry
func addNodes(old, neu []*Node) []*Node {
var nodes []*Node
nodes := make([]*Node, len(neu))
// add all new nodes
for _, n := range neu {
for i, n := range neu {
node := *n
nodes = append(nodes, &node)
nodes[i] = &node
}
// look at old nodes