Skip to content

Commit f842f07

Browse files
authored
perf: make GetEncoder zero alloc (#269)
1 parent e91b533 commit f842f07

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

encoding/encode.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ func RegisterEncoder[T EncoderConstraint](enc T, mime string, aliases ...string)
5151

5252
// GetEncoder returns the response encoder for a given media type.
5353
func GetEncoder(mime string) ResponseEncoder {
54-
mimeParts := strings.Split(mime, ",")
55-
for _, part := range mimeParts {
54+
mimeParts := strings.SplitSeq(mime, ",")
55+
for part := range mimeParts {
5656
if enc, ok := encoders[part]; ok {
5757
return enc
5858
}

0 commit comments

Comments
 (0)