Skip to content

Commit

Permalink
avoid double memory allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
alovak committed Nov 10, 2023
1 parent f2fa0e4 commit 9226221
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion field/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (f *String) Pack() ([]byte, error) {
return nil, fmt.Errorf("failed to encode content: %w", err)
}

runeCount := utf8.RuneCountInString(string(data))
runeCount := utf8.RuneCount(data)

packedLength, err := f.spec.Pref.EncodeLength(f.spec.Length, runeCount)
if err != nil {
Expand Down

0 comments on commit 9226221

Please sign in to comment.