use mapToString where possible

This commit is contained in:
Matthias Radestock
2017-05-29 12:33:46 +01:00
parent f09be95a43
commit 87d91c55d9
2 changed files with 2 additions and 37 deletions

View File

@@ -1,10 +1,8 @@
package report
import (
"bytes"
"fmt"
"reflect"
"sort"
"strconv"
"github.com/ugorji/go/codec"
@@ -109,22 +107,7 @@ func (c EdgeMetadatas) ForEach(fn func(k string, v EdgeMetadata)) {
}
func (c EdgeMetadatas) String() string {
keys := []string{}
if c.psMap == nil {
c = EmptyEdgeMetadatas
}
for _, k := range c.psMap.Keys() {
keys = append(keys, k)
}
sort.Strings(keys)
buf := bytes.NewBufferString("{")
for _, key := range keys {
val, _ := c.psMap.Lookup(key)
fmt.Fprintf(buf, "%s: %v, ", key, val)
}
fmt.Fprintf(buf, "}")
return buf.String()
return mapToString(c.psMap)
}
// DeepEqual tests equality with other Counters

View File

@@ -1,10 +1,7 @@
package report
import (
"bytes"
"fmt"
"reflect"
"sort"
"github.com/ugorji/go/codec"
"github.com/weaveworks/ps"
@@ -109,22 +106,7 @@ func (s Sets) Copy() Sets {
}
func (s Sets) String() string {
if s.psMap == nil {
s = EmptySets
}
keys := []string{}
for _, k := range s.psMap.Keys() {
keys = append(keys, k)
}
sort.Strings(keys)
buf := bytes.NewBufferString("{")
for _, key := range keys {
val, _ := s.psMap.Lookup(key)
fmt.Fprintf(buf, "%s: %v, ", key, val)
}
fmt.Fprintf(buf, "}")
return buf.String()
return mapToString(s.psMap)
}
// DeepEqual tests equality with other Sets