From 0f067d4da7a1f6f44c974aa2ae3a9323c9e70cc5 Mon Sep 17 00:00:00 2001 From: fayfaychan Date: Thu, 31 Mar 2022 11:47:19 -0400 Subject: [PATCH 1/2] Passing capacity to make() in place of length. The second argument is length and not capacity. --- trace/lrumap.go | 2 +- trace/trace.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/trace/lrumap.go b/trace/lrumap.go index 908c2497e..80095a5f6 100644 --- a/trace/lrumap.go +++ b/trace/lrumap.go @@ -44,7 +44,7 @@ func (lm lruMap) len() int { } func (lm lruMap) keys() []interface{} { - keys := make([]interface{}, len(lm.cacheKeys)) + keys := make([]interface{}, 0, len(lm.cacheKeys)) for k := range lm.cacheKeys { keys = append(keys, k) } diff --git a/trace/trace.go b/trace/trace.go index 861df9d39..525f8b8a4 100644 --- a/trace/trace.go +++ b/trace/trace.go @@ -381,7 +381,7 @@ func (s *span) interfaceArrayToAnnotationArray() []Annotation { } func (s *span) lruAttributesToAttributeMap() map[string]interface{} { - attributes := make(map[string]interface{}, s.lruAttributes.len()) + attributes := make(map[string]interface{}, 0, s.lruAttributes.len()) for _, key := range s.lruAttributes.keys() { value, ok := s.lruAttributes.get(key) if ok { @@ -423,7 +423,7 @@ func (s *span) printStringInternal(attributes []Attribute, str string) { now := time.Now() var am map[string]interface{} if len(attributes) != 0 { - am = make(map[string]interface{}, len(attributes)) + am = make(map[string]interface{}, 0, len(attributes)) for _, attr := range attributes { am[attr.key] = attr.value } From ae9b7c841051c8cbd1bf4e1db58aa854d4417258 Mon Sep 17 00:00:00 2001 From: fayfaychan Date: Thu, 31 Mar 2022 12:19:02 -0400 Subject: [PATCH 2/2] Revert changes to maps --- trace/trace.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trace/trace.go b/trace/trace.go index 525f8b8a4..861df9d39 100644 --- a/trace/trace.go +++ b/trace/trace.go @@ -381,7 +381,7 @@ func (s *span) interfaceArrayToAnnotationArray() []Annotation { } func (s *span) lruAttributesToAttributeMap() map[string]interface{} { - attributes := make(map[string]interface{}, 0, s.lruAttributes.len()) + attributes := make(map[string]interface{}, s.lruAttributes.len()) for _, key := range s.lruAttributes.keys() { value, ok := s.lruAttributes.get(key) if ok { @@ -423,7 +423,7 @@ func (s *span) printStringInternal(attributes []Attribute, str string) { now := time.Now() var am map[string]interface{} if len(attributes) != 0 { - am = make(map[string]interface{}, 0, len(attributes)) + am = make(map[string]interface{}, len(attributes)) for _, attr := range attributes { am[attr.key] = attr.value }