Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid unnecessary alloc in MarshalJSON #50

Merged
merged 1 commit into from
Apr 29, 2019
Merged

Avoid unnecessary alloc in MarshalJSON #50

merged 1 commit into from
Apr 29, 2019

Conversation

alcore
Copy link
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