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

Eliminate meaningless to-string conversion #511

Closed
vkostyukov opened this issue Jan 27, 2016 · 1 comment
Closed

Eliminate meaningless to-string conversion #511

vkostyukov opened this issue Jan 27, 2016 · 1 comment

Comments

@vkostyukov
Copy link
Collaborator

When it comes to Netty -> Finagle -> Finch, the HTTP body lifecycle is ChannelBuffer -> Buf -> String -> CaseClass. If we'd be able to teach jawn to work with Buf instead of String, we'd be able to go directly from Buf to CaseClass thereby eliminating that meaningless to-string conversion, which in fact alllocates O(n^2) bytes.

This would be a huge win for Finch users, but this requires some refactoring around DecodeRequest. The idea of top of my head is to actually keep DecodeRequest a string-based type-class and use it for params, headers, etc (i.e., param("foo").as[Int]) and introduce a new type-class FromRequest = Request => A (as a symmetric version to ToResponse) to be able to grab content: Buf from the request if we need it and not perform the to-string conversion. In this case, body readers should use the FromRequest type-class via the as method.

I'm totally fine to start with Circe (make it decode JSON from Buf) and keep the rest of the JSON lirbaries we support working with strings.

@vkostyukov
Copy link
Collaborator Author

Fixed in #671 (kudos to @rpless).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant