Skip to content

Commit

Permalink
optimize:reduce mem-allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
tylitianrui committed Feb 11, 2024
1 parent bdc3cfd commit 41fed4d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scrape/scrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,8 @@ var errBodySizeLimit = errors.New("body size limit exceeded")
// https://www.rfc-editor.org/rfc/rfc9110.html#name-accept defines.
// No validation is here, we expect scrape protocols to be validated already.
func acceptHeader(sps []config.ScrapeProtocol) string {
var vals []string
vals := make([]string, len(sps)+1)
vals = vals[:0]
weight := len(config.ScrapeProtocolsHeaders) + 1
for _, sp := range sps {
vals = append(vals, fmt.Sprintf("%s;q=0.%d", config.ScrapeProtocolsHeaders[sp], weight))
Expand Down

0 comments on commit 41fed4d

Please sign in to comment.