Skip to content

Remove unnecessary allocs on JSON #1191

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

Closed
wants to merge 1 commit into from
Closed

Remove unnecessary allocs on JSON #1191

wants to merge 1 commit into from

Conversation

ribice
Copy link
Contributor

@ribice ribice commented Sep 7, 2018

Added new method to keep backwards compatibility (for those directly using JSONBlob).

Removes the alloc in JSON method to []byte (json.Marshal(i)) and directly writes to http.ResponseWriter.

@ribice
Copy link
Contributor Author

ribice commented Sep 7, 2018

I can fix the failing test, if you are interested in this change?

@im-kulikov
Copy link
Contributor

im-kulikov commented Sep 19, 2018

Good idea.. @vishr / @alexaandru what you think about?

return
}
return c.JSONBlob(code, b)
return c.jsonBlob(code, i)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since jsonBlob is simple, the code can be moved directly here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah! nice job

@vishr
Copy link
Member

vishr commented Sep 28, 2018

@ribice I think we should do it the same for JSONP and XML too.

@stale
Copy link

stale bot commented Nov 30, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 30, 2018
@stale stale bot closed this Dec 7, 2018
vishr pushed a commit that referenced this pull request Jan 14, 2019
* [extend #1191] Unnecessary alloc for XML, JSON, JSONP

* add legacy (JSON/JSONP/XML)Blob tests

* fix namings

* fix `jsonPBlob` allocs

* fix review comments (thx @alexaandru)

* fix review comments (thx @alexaandru)
add benchmarks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants