Skip to content

Commit

Permalink
Remove unnecessary allocations from readMIMEHeader (#1609)
Browse files Browse the repository at this point in the history
Signed-off-by: Neil Twigg <neil@nats.io>
  • Loading branch information
neilalexander committed Apr 15, 2024
1 parent 1eafa27 commit cdc50de
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -3753,7 +3753,7 @@ func readMIMEHeader(tp *textproto.Reader) (textproto.MIMEHeader, error) {
}

// Process key fetching original case.
i := bytes.IndexByte([]byte(kv), ':')
i := strings.IndexByte(kv, ':')
if i < 0 {
return nil, ErrBadHeaderMsg
}
Expand All @@ -3766,8 +3766,7 @@ func readMIMEHeader(tp *textproto.Reader) (textproto.MIMEHeader, error) {
for i < len(kv) && (kv[i] == ' ' || kv[i] == '\t') {
i++
}
value := string(kv[i:])
m[key] = append(m[key], value)
m[key] = append(m[key], kv[i:])
if err != nil {
return m, err
}
Expand Down

0 comments on commit cdc50de

Please sign in to comment.