Commit 0d772244 authored by Todd Neal's avatar Todd Neal Committed by Brad Fitzpatrick

http2/hpack: remove pair function and initialize directly

Inlining isn't performed on generated init functions.  Removing the pair
function and initializing the structs directly saves another 16k on a
simple http.ListenAndServe() binary.

delta   name                                      old      new
-58     runtime.findfunctab                       10471    10413         -0.55%
-41     runtime.gcbss                             910      869           -4.51%
41      runtime.gcdata                            612      653            6.70%
-408    runtime.pclntab                           1036311  1035903       -0.04%
-11711  vendor/golang_org/x/net/http2/hpack.init  12283    572          -95.34%

Updates golang/go#6853

Change-Id: Ibccc796fe7403674cf4b4561acf9551d76ff11e8
Reviewed-on: https://go-review.googlesource.com/43190
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 51392906
......@@ -132,67 +132,67 @@ func pair(name, value string) HeaderField {
// http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#appendix-B
var staticTable = newStaticTable()
var staticTableEntries = [...]HeaderField{
pair(":authority", ""),
pair(":method", "GET"),
pair(":method", "POST"),
pair(":path", "/"),
pair(":path", "/index.html"),
pair(":scheme", "http"),
pair(":scheme", "https"),
pair(":status", "200"),
pair(":status", "204"),
pair(":status", "206"),
pair(":status", "304"),
pair(":status", "400"),
pair(":status", "404"),
pair(":status", "500"),
pair("accept-charset", ""),
pair("accept-encoding", "gzip, deflate"),
pair("accept-language", ""),
pair("accept-ranges", ""),
pair("accept", ""),
pair("access-control-allow-origin", ""),
pair("age", ""),
pair("allow", ""),
pair("authorization", ""),
pair("cache-control", ""),
pair("content-disposition", ""),
pair("content-encoding", ""),
pair("content-language", ""),
pair("content-length", ""),
pair("content-location", ""),
pair("content-range", ""),
pair("content-type", ""),
pair("cookie", ""),
pair("date", ""),
pair("etag", ""),
pair("expect", ""),
pair("expires", ""),
pair("from", ""),
pair("host", ""),
pair("if-match", ""),
pair("if-modified-since", ""),
pair("if-none-match", ""),
pair("if-range", ""),
pair("if-unmodified-since", ""),
pair("last-modified", ""),
pair("link", ""),
pair("location", ""),
pair("max-forwards", ""),
pair("proxy-authenticate", ""),
pair("proxy-authorization", ""),
pair("range", ""),
pair("referer", ""),
pair("refresh", ""),
pair("retry-after", ""),
pair("server", ""),
pair("set-cookie", ""),
pair("strict-transport-security", ""),
pair("transfer-encoding", ""),
pair("user-agent", ""),
pair("vary", ""),
pair("via", ""),
pair("www-authenticate", ""),
HeaderField{Name: ":authority"},
HeaderField{Name: ":method", Value: "GET"},
HeaderField{Name: ":method", Value: "POST"},
HeaderField{Name: ":path", Value: "/"},
HeaderField{Name: ":path", Value: "/index.html"},
HeaderField{Name: ":scheme", Value: "http"},
HeaderField{Name: ":scheme", Value: "https"},
HeaderField{Name: ":status", Value: "200"},
HeaderField{Name: ":status", Value: "204"},
HeaderField{Name: ":status", Value: "206"},
HeaderField{Name: ":status", Value: "304"},
HeaderField{Name: ":status", Value: "400"},
HeaderField{Name: ":status", Value: "404"},
HeaderField{Name: ":status", Value: "500"},
HeaderField{Name: "accept-charset"},
HeaderField{Name: "accept-encoding", Value: "gzip, deflate"},
HeaderField{Name: "accept-language"},
HeaderField{Name: "accept-ranges"},
HeaderField{Name: "accept"},
HeaderField{Name: "access-control-allow-origin"},
HeaderField{Name: "age"},
HeaderField{Name: "allow"},
HeaderField{Name: "authorization"},
HeaderField{Name: "cache-control"},
HeaderField{Name: "content-disposition"},
HeaderField{Name: "content-encoding"},
HeaderField{Name: "content-language"},
HeaderField{Name: "content-length"},
HeaderField{Name: "content-location"},
HeaderField{Name: "content-range"},
HeaderField{Name: "content-type"},
HeaderField{Name: "cookie"},
HeaderField{Name: "date"},
HeaderField{Name: "etag"},
HeaderField{Name: "expect"},
HeaderField{Name: "expires"},
HeaderField{Name: "from"},
HeaderField{Name: "host"},
HeaderField{Name: "if-match"},
HeaderField{Name: "if-modified-since"},
HeaderField{Name: "if-none-match"},
HeaderField{Name: "if-range"},
HeaderField{Name: "if-unmodified-since"},
HeaderField{Name: "last-modified"},
HeaderField{Name: "link"},
HeaderField{Name: "location"},
HeaderField{Name: "max-forwards"},
HeaderField{Name: "proxy-authenticate"},
HeaderField{Name: "proxy-authorization"},
HeaderField{Name: "range"},
HeaderField{Name: "referer"},
HeaderField{Name: "refresh"},
HeaderField{Name: "retry-after"},
HeaderField{Name: "server"},
HeaderField{Name: "set-cookie"},
HeaderField{Name: "strict-transport-security"},
HeaderField{Name: "transfer-encoding"},
HeaderField{Name: "user-agent"},
HeaderField{Name: "vary"},
HeaderField{Name: "via"},
HeaderField{Name: "www-authenticate"},
}
func newStaticTable() *headerFieldTable {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment