-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Labels
I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.
Milestone
Description
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:
- Every function that returns
~strbut could also return an&strwill get changed to do so. If users want to have an explicit copy, they have to callto_uniqe()or similar. - Every function that returns an
~[~str]but could also return return a list of&strwill get rewritten under an other name to work as an iterator that takes anfn(&str) -> boolclosure. The original name still remains, and will just wrap that iterator in an ~[~str]. - Remove the
viewfunctions, make thesliceones return&str(mirrors recent change tovec)
Metadata
Metadata
Assignees
Labels
I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.