Comments (6)
Yes could leverage iodata and to some extend maybe a bit of https://github.com/benoitc/hackney/blob/master/doc/hackney_url.md
from stripity-stripe.
If your goal is to remove the ++ operation (which I understand for performance reasons) wouldn't the simple fix be something like this?
diff --git a/lib/stripe/uri.ex b/lib/stripe/uri.ex
index 7aa1bd9..5cfc55a 100644
--- a/lib/stripe/uri.ex
+++ b/lib/stripe/uri.ex
@@ -48,9 +48,9 @@ defmodule Stripe.URI do
Enum.map_join values, "&", fn {key, value} ->
cond do
Enumerable.impl_for(value) ->
- pair(root, parents ++ [key], value)
+ pair(root, [key | parents], value)
true ->
- build_key(root, parents ++ [key]) <> URI.encode_www_form(to_string(value))
+ build_key(root, Enum.reverse([key | parents])) <> URI.encode_www_form(to_string(value))
end
end
end
or do you want to avoid Enum.reverse as well? I haven't read the source on that one but I assumed one round of it was OK.
from stripity-stripe.
Pull request submitted: #184
from stripity-stripe.
Yeah. I have an implementation using iodata in another system. I may just copy it over.
from stripity-stripe.
The Enum.reverse
is fine. The problem with ++
is the way the memory allocation and copy-on-write mechanism works with the VM.
The solution that you have given looks like an improvement, but I think the overall logic (such as use of Enumerable.impl_for/1
) can be improved.
from stripity-stripe.
@fastjames given that I think if you want to open a PR to spike this out and see if @DavidAntaramian or someone else can provide feedback on that, I'd be really thankful!
from stripity-stripe.
Related Issues (20)
- Missing Jason.Encoder implementation for Stripe.Customer
- `Stripe.BillingPortal.Configuration` fails to load
- Stripe.Converter.convert_result not returning struct
- FunctionClauseError when using Stripe.PaymentMethod.attach HOT 2
- [Proposal] Make param from Stripe.Error to be a string instead of atom HOT 2
- Cutting a Release HOT 16
- OpenApi struct is undefined HOT 7
- [Question] How to guarantee order of body params HOT 1
- Stripe.TestClock is undefined HOT 1
- Odd url generation for BillingPortal.Session HOT 5
- `Stripe.Account.create_login_link` has wrong return type spec HOT 3
- Open api url issue with stripe invoice finalization HOT 5
- Stripe.Webhook fails to process message for "financial_connections.account.created" HOT 5
- Stripe.Account.create has an incomplete spec HOT 7
- Request.put_endpoint/2 doesn't function as described HOT 3
- warning: Stripe.Session.retrieve/1 is undefined (module Stripe.Session is not available or is yet) HOT 1
- `Stripe.Account.retrieve` does not allow for account id HOT 4
- Possibly missing `id` (for SubscriptionItem) on `items` type signature for `Subscription`. HOT 7
- Custom fields checkout typespec is wrong HOT 4
- Unable to retrieve test clocks from Stripe due to invalid struct name HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stripity-stripe.