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
No known key found for this signature in database
GPG Key ID: 8B31058CC55DFD4F

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