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 { ...@@ -132,67 +132,67 @@ func pair(name, value string) HeaderField {
// http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#appendix-B // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#appendix-B
var staticTable = newStaticTable() var staticTable = newStaticTable()
var staticTableEntries = [...]HeaderField{ var staticTableEntries = [...]HeaderField{
pair(":authority", ""), HeaderField{Name: ":authority"},
pair(":method", "GET"), HeaderField{Name: ":method", Value: "GET"},
pair(":method", "POST"), HeaderField{Name: ":method", Value: "POST"},
pair(":path", "/"), HeaderField{Name: ":path", Value: "/"},
pair(":path", "/index.html"), HeaderField{Name: ":path", Value: "/index.html"},
pair(":scheme", "http"), HeaderField{Name: ":scheme", Value: "http"},
pair(":scheme", "https"), HeaderField{Name: ":scheme", Value: "https"},
pair(":status", "200"), HeaderField{Name: ":status", Value: "200"},
pair(":status", "204"), HeaderField{Name: ":status", Value: "204"},
pair(":status", "206"), HeaderField{Name: ":status", Value: "206"},
pair(":status", "304"), HeaderField{Name: ":status", Value: "304"},
pair(":status", "400"), HeaderField{Name: ":status", Value: "400"},
pair(":status", "404"), HeaderField{Name: ":status", Value: "404"},
pair(":status", "500"), HeaderField{Name: ":status", Value: "500"},
pair("accept-charset", ""), HeaderField{Name: "accept-charset"},
pair("accept-encoding", "gzip, deflate"), HeaderField{Name: "accept-encoding", Value: "gzip, deflate"},
pair("accept-language", ""), HeaderField{Name: "accept-language"},
pair("accept-ranges", ""), HeaderField{Name: "accept-ranges"},
pair("accept", ""), HeaderField{Name: "accept"},
pair("access-control-allow-origin", ""), HeaderField{Name: "access-control-allow-origin"},
pair("age", ""), HeaderField{Name: "age"},
pair("allow", ""), HeaderField{Name: "allow"},
pair("authorization", ""), HeaderField{Name: "authorization"},
pair("cache-control", ""), HeaderField{Name: "cache-control"},
pair("content-disposition", ""), HeaderField{Name: "content-disposition"},
pair("content-encoding", ""), HeaderField{Name: "content-encoding"},
pair("content-language", ""), HeaderField{Name: "content-language"},
pair("content-length", ""), HeaderField{Name: "content-length"},
pair("content-location", ""), HeaderField{Name: "content-location"},
pair("content-range", ""), HeaderField{Name: "content-range"},
pair("content-type", ""), HeaderField{Name: "content-type"},
pair("cookie", ""), HeaderField{Name: "cookie"},
pair("date", ""), HeaderField{Name: "date"},
pair("etag", ""), HeaderField{Name: "etag"},
pair("expect", ""), HeaderField{Name: "expect"},
pair("expires", ""), HeaderField{Name: "expires"},
pair("from", ""), HeaderField{Name: "from"},
pair("host", ""), HeaderField{Name: "host"},
pair("if-match", ""), HeaderField{Name: "if-match"},
pair("if-modified-since", ""), HeaderField{Name: "if-modified-since"},
pair("if-none-match", ""), HeaderField{Name: "if-none-match"},
pair("if-range", ""), HeaderField{Name: "if-range"},
pair("if-unmodified-since", ""), HeaderField{Name: "if-unmodified-since"},
pair("last-modified", ""), HeaderField{Name: "last-modified"},
pair("link", ""), HeaderField{Name: "link"},
pair("location", ""), HeaderField{Name: "location"},
pair("max-forwards", ""), HeaderField{Name: "max-forwards"},
pair("proxy-authenticate", ""), HeaderField{Name: "proxy-authenticate"},
pair("proxy-authorization", ""), HeaderField{Name: "proxy-authorization"},
pair("range", ""), HeaderField{Name: "range"},
pair("referer", ""), HeaderField{Name: "referer"},
pair("refresh", ""), HeaderField{Name: "refresh"},
pair("retry-after", ""), HeaderField{Name: "retry-after"},
pair("server", ""), HeaderField{Name: "server"},
pair("set-cookie", ""), HeaderField{Name: "set-cookie"},
pair("strict-transport-security", ""), HeaderField{Name: "strict-transport-security"},
pair("transfer-encoding", ""), HeaderField{Name: "transfer-encoding"},
pair("user-agent", ""), HeaderField{Name: "user-agent"},
pair("vary", ""), HeaderField{Name: "vary"},
pair("via", ""), HeaderField{Name: "via"},
pair("www-authenticate", ""), HeaderField{Name: "www-authenticate"},
} }
func newStaticTable() *headerFieldTable { 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