]> Cypherpunks repositories - gostls13.git/commit
net/http: improve performance for parsePostForm
authorQuentin Renard <contact@asticode.com>
Sun, 6 Mar 2016 16:27:50 +0000 (17:27 +0100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 4 Oct 2016 20:05:02 +0000 (20:05 +0000)
commit59320c396e6448132a52cb5a5d96491eee1e0ad8
treeafe98d8b4f7254367c58944f8a835ae25db088a8
parente6051de0351bb05d7409ee0d483f932e3530f816
net/http: improve performance for parsePostForm

Remove the use of io.ReadAll in http.parsePostForm to avoid converting
the whole input from []byte to string and not performing well
space-allocated-wise.

Instead a new function called parsePostFormURLEncoded is used and is
fed directly an io.Reader that is parsed using a bufio.Reader.

Benchmark:

name         old time/op    new time/op    delta
PostQuery-4    2.90µs ± 6%    2.82µs ± 4%     ~       (p=0.094 n=9+9)

name         old alloc/op   new alloc/op   delta
PostQuery-4    1.05kB ± 0%    0.90kB ± 0%  -14.49%  (p=0.000 n=10+10)

name         old allocs/op  new allocs/op  delta
PostQuery-4      6.00 ± 0%      7.00 ± 0%  +16.67%  (p=0.000 n=10+10)

Fixes #14655

Change-Id: I112c263d4221d959ed6153cfe88bc57a2aa8ea73
Reviewed-on: https://go-review.googlesource.com/20301
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/net/http/request.go
src/net/http/request_test.go