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

ToEncodedUrlPiece #50

Merged
merged 3 commits into from
Apr 10, 2017
Merged

ToEncodedUrlPiece #50

merged 3 commits into from
Apr 10, 2017

Conversation

fizruk
Copy link
Owner

@fizruk fizruk commented Apr 10, 2017

This PR is based on #47 and adds efficient implementations for toEncodedUrlPiece together with some tests.

@phadej could you take a look?

@fizruk
Copy link
Owner Author

fizruk commented Apr 10, 2017

We could also implement more efficient versions of toEncodedUrlPiece for Maybe and Either... but I wonder who uses those anyway.

@phadej
Copy link
Collaborator

phadej commented Apr 10, 2017

Seems fine. Have you benchmarked (or do you real world example) that this really matters?

@fizruk
Copy link
Owner Author

fizruk commented Apr 10, 2017

I did not perform a proper benchmarking, but it should matter, considering that URL-encoding demands per-char processing. A quick test in GHCi reveals at least some difference:

>>> :set +s
>>> import qualified Data.ByteString.Lazy as BSL
>>> import Data.ByteString.Builder (toLazyByteString)
>>> let check f = sum . map (BSL.length . toLazyByteString . f)
>>> check (toEncodedUrlPiece . toUrlPiece) [1..10000000]
68888897
(22.59 secs, 72,137,670,104 bytes)
>>> check toEncodedUrlPiece [1..10000000]
68888897
(15.44 secs, 55,719,891,472 bytes)

OTOH, now that I think of it,toEncodedUrlPiece only happens on clients, so it probably isn't much of a performance concern.

Copy link
Collaborator

@phadej phadej left a comment

Choose a reason for hiding this comment

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

LGTM

@fizruk fizruk merged commit 19f79be into master Apr 10, 2017
@fizruk fizruk deleted the toEncodedUrlPiece branch April 10, 2017 14:38
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.

None yet

3 participants