Skip to content

net/http/internal/http2: pre-allocate header map in server's newWriterAndRequest #80234

Description

In src/net/http/internal/http2/server.go, the function newWriterAndRequest constructs a new request and its header map when parsing an incoming HTTP/2 request frame.
Currently, the map is created using make(Header) without specifying an initial capacity:

header := make(Header)
rp.Header = header
for _, hf := range f.RegularFields() {
    header.Add(sc.canonicalHeader(hf.Name), hf.Value)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixPendingIssues that have a fix which has not yet been reviewed or submitted.Performance

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions