From 96df2700fd6dd9db6e751fb391da5bc158a4de58 Mon Sep 17 00:00:00 2001 From: reesporte Date: Mon, 11 Apr 2022 09:34:06 -0500 Subject: [PATCH] save space when union-ing DistinctTimestamps By using an empty struct, we reduce memory usage by up to 16 bytes (the size of a timestamp string) --- executor.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/executor.go b/executor.go index 3d9580e62..bde4830c1 100644 --- a/executor.go +++ b/executor.go @@ -1617,12 +1617,12 @@ func (d DistinctTimestamp) ToRows(callback func(*proto.RowResponse) error) error // Union returns the union of the values of `d` and `other` func (d *DistinctTimestamp) Union(other DistinctTimestamp) DistinctTimestamp { - both := map[string]string{} + both := map[string]struct{}{} for _, val := range d.Values { - both[val] = val + both[val] = struct{}{} } for _, val := range other.Values { - both[val] = val + both[val] = struct{}{} } vals := []string{} for key := range both {