From 0ab3e72520b5a98f8e962b02a2a721afde269010 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Tue, 18 Sep 2018 14:09:52 -0500 Subject: [PATCH] refactor mergeGroupCounts function --- executor.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/executor.go b/executor.go index 0fb6f53a7..858c88d9e 100644 --- a/executor.go +++ b/executor.go @@ -834,20 +834,13 @@ type GroupCount struct { } func mergeGroupCounts(gc, other []GroupCount) []GroupCount { - m := make(map[string]struct { - i int - count uint64 - }) + m := make(map[string]int) for i := range gc { - m[uniqueGroupString(gc[i].Group)] = struct { - i int - count uint64 - }{i, gc[i].Count} + m[uniqueGroupString(gc[i].Group)] = i } for i := range other { - o, found := m[uniqueGroupString(other[i].Group)] - if found { - gc[o.i].Count += other[i].Count + if idx, found := m[uniqueGroupString(other[i].Group)]; found { + gc[idx].Count += other[i].Count } else { gc = append(gc, other[i]) }