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

Improve URI module efficiency #184

Closed
wants to merge 2 commits into from

Conversation

fastjames
Copy link

@fastjames fastjames commented Jan 4, 2017

The Stripe.URI module used a less-efficient method for building the HTTP query params string. Here, we switch to a more efficient list prepend and reverse pattern. Also, the recursive parser made use of Enumerable.impl_for/1 which is fairly heavyweight. By checking for maps or lists (which are assumed to be keyword lists) we can remove impl_for. I wish I could DRY up that check, but the small difference between the guard and non-guard syntax prevents it.

Addresses #105

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.04%) to 24.074% when pulling 23f79f7 on geminimvp:uri_efficiency into f6ddf08 on code-corps:2.0.

@fastjames fastjames mentioned this pull request Jan 4, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-1.7%) to 23.423% when pulling 7613a42 on geminimvp:uri_efficiency into f6ddf08 on code-corps:2.0.

@joshsmith
Copy link
Contributor

@DavidAntaramian @SViccari would you mind reviewing?

@joshsmith
Copy link
Contributor

@asummers this definitely goes away with your changes being pulled in, right?

@asummers
Copy link
Contributor

It would. Any performance problems would be the purview of the dependency library.

@joshsmith
Copy link
Contributor

@fastjames have you looked at this URI library we're talking about at all? Any indication it suffers some of the same problems?

@joshsmith
Copy link
Contributor

@fastjames I'm closing since it's outdated (we're using a dependency library), but thanks for the contribution. Let me know if you have an answer to my previous question at all.

@joshsmith joshsmith closed this Mar 10, 2017
@fastjames
Copy link
Author

@joshsmith sorry for the delay -- it looks like the dependency library uses reduce |> reverse, so it should be fine.
https://github.com/shhavel/uri_query/blob/master/lib/uri_query.ex#L35

@joshsmith joshsmith reopened this May 17, 2017
@joshsmith joshsmith closed this May 17, 2017
@joshsmith
Copy link
Contributor

Thanks for the update @fastjames!

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

4 participants