You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if url had any plans to add more support for not allocating intermediate strings, especially when adding query parameters. Right now, &str is needed in order to pass to a parameter, so if I have the data represented as anything else (like a stack allocated endpoint-specific type), I have to allocate an extra string per query parameter every time I create a new URL.
Would it be within the scope of url to add support for arbitrary Display types to Serializer::append_pair?
) just directly pushes these &str values to the string anyways, so I think it would be completely feasible to support Display types here, and just use write!() instead.
I'm guessing this wouldn't be possible at all to use if EncodingOverride was enabled, since the encoding crate seems to operate completely on string slices as well, but it would be a much more efficient option when it wasn't enabled.
If this is within the scope of url, I'd be willing to spend some time implementing it - I would at least think it would be useful to not do additional allocations for each url query.
Then again, maybe this would just be a useless micro-optimization. I don't know enough about the internals of url to know whether this is in scope, so I'll just leave this open for more seasoned contributor comments, if any?
The text was updated successfully, but these errors were encountered:
Hi!
I was wondering if
url
had any plans to add more support for not allocating intermediate strings, especially when adding query parameters. Right now,&str
is needed in order to pass to a parameter, so if I have the data represented as anything else (like a stack allocated endpoint-specific type), I have to allocate an extra string per query parameter every time I create a new URL.Would it be within the scope of
url
to add support for arbitraryDisplay
types toSerializer::append_pair
?It seems this method (
rust-url/src/form_urlencoded.rs
Line 360 in e461e34
&str
values to the string anyways, so I think it would be completely feasible to supportDisplay
types here, and just usewrite!()
instead.I'm guessing this wouldn't be possible at all to use if
EncodingOverride
was enabled, since the encoding crate seems to operate completely on string slices as well, but it would be a much more efficient option when it wasn't enabled.If this is within the scope of
url
, I'd be willing to spend some time implementing it - I would at least think it would be useful to not do additional allocations for each url query.Then again, maybe this would just be a useless micro-optimization. I don't know enough about the internals of
url
to know whether this is in scope, so I'll just leave this open for more seasoned contributor comments, if any?The text was updated successfully, but these errors were encountered: