Skip to content

Commit

Permalink
Optimize compact map field names concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
fxamacker committed Oct 20, 2023
1 parent 3688e89 commit 87e6b6b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions typeinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"encoding/binary"
"fmt"
"sort"
"strings"

"github.com/fxamacker/cbor/v2"
)
Expand Down Expand Up @@ -418,9 +419,12 @@ func (fn *fieldNameSorter) Swap(i, j int) {
}

func (fn *fieldNameSorter) join(sep string) string {
var s string
for _, i := range fn.index {
s += sep + fn.names[i].ID()
var sb strings.Builder
for i, index := range fn.index {
if i > 0 {
sb.WriteString(sep)
}
sb.WriteString(fn.names[index].ID())
}
return s
return sb.String()
}

0 comments on commit 87e6b6b

Please sign in to comment.