Skip to content

Optimize ValuesMapToMeta()

Mikhail Mazurskiy requested to merge ash2k/optimize-val-to-meta into master

The more headers there is, the better the new code will perform compared to the old code.

Original code:
BenchmarkValuesMapToMeta-10    	 3360139	       342.8 ns/op	     560 B/op	       7 allocs/op

New code:
BenchmarkValuesMapToMeta-10    	 3642054	       319.1 ns/op	     560 B/op	       3 allocs/op

The initial motivator was to avoid allocating an empty map and just returning nil when input is empty. This is a common case for HTTP trailers.

Edited by Mikhail Mazurskiy

Merge request reports