From 56557cca5b848c68fba9cc7b16593d3c4b14a4df Mon Sep 17 00:00:00 2001 From: Jitendra Ojha Date: Fri, 21 Feb 2020 12:18:55 +0530 Subject: [PATCH] Uses struct{}{} instead of bool for sets via map --- scope.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scope.go b/scope.go index 21d98ad6..15054ac3 100644 --- a/scope.go +++ b/scope.go @@ -1324,7 +1324,8 @@ func (scope *Scope) autoIndex() *Scope { } func (scope *Scope) getColumnAsArray(columns []string, values ...interface{}) (results [][]interface{}) { - resultMap := make(map[string]bool) + keyExists := struct{}{} + resultsKeys := make(map[string]struct{}) for _, value := range values { indirectValue := indirect(reflect.ValueOf(value)) @@ -1344,8 +1345,8 @@ func (scope *Scope) getColumnAsArray(columns []string, values ...interface{}) (r if hasValue { h := fmt.Sprint(result...) - if _, exist := resultMap[h]; !exist { - resultMap[h] = true + if _, exist := resultsKeys[h]; !exist { + resultsKeys[h] = keyExists results = append(results, result) } } @@ -1363,8 +1364,8 @@ func (scope *Scope) getColumnAsArray(columns []string, values ...interface{}) (r if hasValue { h := fmt.Sprint(result...) - if _, exist := resultMap[h]; !exist { - resultMap[h] = true + if _, exist := resultsKeys[h]; !exist { + resultsKeys[h] = keyExists results = append(results, result) } }