Skip to content

Commit

Permalink
only sort maps, not slices
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed May 8, 2024
1 parent cc6e48e commit 7d4fe30
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
10 changes: 1 addition & 9 deletions log/keyvalue.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,7 @@ func (v Value) Equal(w Value) bool {
case KindFloat64:
return v.asFloat64() == w.asFloat64()
case KindSlice:
sv := v.asSlice()
sw := w.asSlice()
slices.SortFunc(sv, func(a, b Value) int {
return cmp.Compare(a.String(), b.String())
})
slices.SortFunc(sw, func(a, b Value) int {
return cmp.Compare(a.String(), b.String())
})
return slices.EqualFunc(sv, sw, Value.Equal)
return slices.EqualFunc(v.asSlice(), w.asSlice(), Value.Equal)
case KindMap:
sv := v.asMap()
slices.SortFunc(sv, func(a, b KeyValue) int {
Expand Down
4 changes: 0 additions & 4 deletions log/keyvalue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ func TestSortedValueEqual(t *testing.T) {
value log.Value
value2 log.Value
}{
{
value: log.SliceValue(log.IntValue(3), log.StringValue("foo")),
value2: log.SliceValue(log.StringValue("foo"), log.IntValue(3)),
},
{
value: log.MapValue(
log.Slice("l", log.IntValue(3), log.StringValue("foo")),
Expand Down

0 comments on commit 7d4fe30

Please sign in to comment.