]> Cypherpunks repositories - gostls13.git/commit
net/http: optimize StatusText implementation
authorJoão Penteado <4219131+joaopenteado@users.noreply.github.com>
Tue, 30 Nov 2021 18:59:41 +0000 (18:59 +0000)
committerDamien Neil <dneil@google.com>
Fri, 15 Apr 2022 17:03:50 +0000 (17:03 +0000)
commitac01de5446ec92544768dabee3b0d1faf5f596d9
tree8d74a1fbaf07cf4ad3bb91b13e46c6e3c205ec5d
parent082cfabf126d63e952e1ac29d47c2a47f1c64bee
net/http: optimize StatusText implementation

The current implementation, although more succinct, relies on a runtime
lookup to a "constant" unexported map (which also needs to be
initialized at runtime).

The proposed implementation is able to be optimized by the compiler at
build-time, resulting in *much* more efficient instructions.
Additionally, unused string literals may even be removed altogether
from the generated binary in some cases.

This change is fully backwards-compatible behavior-wise with the
existing implementation.

Change-Id: I36450320aacff5b322195820552f2831d4fecd52
GitHub-Last-Rev: e2058f132ef7a193529d4b0e84329ac93e5d1dcb
GitHub-Pull-Request: golang/go#49811
Reviewed-on: https://go-review.googlesource.com/c/go/+/367201
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
src/net/http/response.go
src/net/http/server.go
src/net/http/status.go