str module allocates too much; proposal for improvement #5427
Labels
I-slow
Issue: Problems and improvements with respect to performance of generated code.
Milestone
I was looking over the str module and noticed that a lot of the functions there do unnecessary allocations. I counted ~20 functions that return either an
~str
or~[~str]
where a&str
or a bunch of&str
would do. (they're mostly search / trim functions)I'd like to change them, however I'm not sure if that would be the best way in regards to API design.
My proposal is:
~str
but could also return an&str
will get changed to do so. If users want to have an explicit copy, they have to callto_uniqe()
or similar.~[~str]
but could also return return a list of&str
will get rewritten under an other name to work as an iterator that takes anfn(&str) -> bool
closure. The original name still remains, and will just wrap that iterator in an ~[~str].view
functions, make theslice
ones return&str
(mirrors recent change tovec
)The text was updated successfully, but these errors were encountered: