• Quentin Renard's avatar
    net/http: improve performance for parsePostForm · 59320c39
    Quentin Renard authored
    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/20301Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    59320c39
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...