• Clayton Coleman's avatar
    Avoid allocations when building SelfLinks and fast path escape · 389a8436
    Clayton Coleman authored
    A self link should only require one allocation, and we should skip
    url.PathEscape() except when the path actually needs it.
    
    Add a fuzz test to build random strings and verify them against
    the optimized implementation. Add a new BenchmarkWatchHTTP_UTF8 that
    covers when we have unicode names in the self link.
    
    ```
    > before
    BenchmarkGet-12          	   10000	    118863 ns/op	   17482 B/op	     130 allocs/op
    BenchmarkWatchHTTP-12    	   30000	     38346 ns/op	    1893 B/op	      29 allocs/op
    
    > after
    BenchmarkGet-12               	   10000	    116218 ns/op	   17456 B/op	     130 allocs/op
    BenchmarkWatchHTTP-12         	   50000	     35988 ns/op	    1571 B/op	      26 allocs/op
    BenchmarkWatchHTTP_UTF8-12    	   50000	     41467 ns/op	    1928 B/op	      28 allocs/op
    ```
    
    Saves 3 allocations in the fast path and 1 in the slow path (the
    slow path has to build the buffer and then call url.EscapedPath
    which always allocates).
    389a8436
Name
Last commit
Last update
..
publishing Loading commit data...
src Loading commit data...
BUILD Loading commit data...
OWNERS Loading commit data...
README.md Loading commit data...
repos_generated.bzl Loading commit data...