• Andrew Gerrand's avatar
    net/url: use bytes.Buffer in (*URL).String · da82dfac
    Andrew Gerrand authored
    BenchmarkString before:
    
            11990 ns/op            1621 B/op         73 allocs/op
    
    Using bytes.Buffer:
    
            8774 ns/op            1994 B/op         40 allocs/op
    
    I also tried making a version of escape() that writes directly to the
    bytes.Buffer, but it only saved 1 alloc/op and increased CPU time by
    about 10%. Didn't seem worth the extra code path.
    
    R=bradfitz
    CC=golang-dev
    https://golang.org/cl/7182050
    da82dfac
url.go 16.5 KB