Skip to content

Avoid unnecessary alloc in MarshalJSON#50

Merged
rs merged 1 commit intors:masterfrom
alcore:marshal-json
Apr 29, 2019
Merged

Avoid unnecessary alloc in MarshalJSON#50
rs merged 1 commit intors:masterfrom
alcore:marshal-json

Conversation

@alcore
Copy link
Copy Markdown
Contributor

@alcore alcore commented Apr 28, 2019

As per title, 1 alloc within MarshalJSON can be avoided at the cost of a tiny bit of duplication.

benchmark                  old ns/op     new ns/op     delta
BenchmarkMarshalJSON-8     45.1          32.0          -29.05%

benchmark                  old allocs    new allocs    delta
BenchmarkMarshalJSON-8     2             1             -50.00%

benchmark                  old bytes     new bytes     delta
BenchmarkMarshalJSON-8     64            32            -50.00%

Signed-off-by: Michał Chojnacki <m.chojnacki@muyo.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants