Skip to content

Commit

Permalink
Update trace/tracestate.go
Browse files Browse the repository at this point in the history
Co-authored-by: Tyler Yahn <[email protected]>
  • Loading branch information
xiehuc and MrAlias authored Nov 30, 2023
1 parent 43a42e4 commit 7efdc0c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions trace/tracestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,16 @@ func (ts TraceState) String() string {
if len(ts.list) == 0 {
return ""
}
var n int
n += len(ts.list) // member delimiters: '='
n += len(ts.list) - 1 // list delimiters: ','
for _, mem := range ts.list {
n += len(mem.Key)
n += len(mem.Value)
}

var sb strings.Builder
sb.Grow(n)
_, _ = sb.WriteString(ts.list[0].Key)
_ = sb.WriteByte('=')
_, _ = sb.WriteString(ts.list[0].Value)
Expand Down

0 comments on commit 7efdc0c

Please sign in to comment.