From 3a855d362f8bf6851d86f024136056d00d42bfc0 Mon Sep 17 00:00:00 2001 From: James Phillips Date: Fri, 26 Aug 2016 16:34:28 -0700 Subject: [PATCH] Preallocates result struct, which was a profiling hot spot. --- consul/state/state_store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consul/state/state_store.go b/consul/state/state_store.go index 7949d89f12..1f92e26e01 100644 --- a/consul/state/state_store.go +++ b/consul/state/state_store.go @@ -1248,7 +1248,7 @@ func (s *StateStore) parseCheckServiceNodes( return 0, nil, err } - var results structs.CheckServiceNodes + results := make(structs.CheckServiceNodes, 0, len(services)) for _, sn := range services { // Retrieve the node. n, err := tx.First("nodes", "id", sn.Node)