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

Support IntoIterator<Item = String> in flamegraph::from_lines #230

Open
itamarst opened this issue Feb 8, 2022 · 1 comment
Open

Support IntoIterator<Item = String> in flamegraph::from_lines #230

itamarst opened this issue Feb 8, 2022 · 1 comment

Comments

@itamarst
Copy link
Contributor

itamarst commented Feb 8, 2022

Right now this API takes IntoIterator<Item = &'a str> and it's a pain to turn IntoIterator<Item = String> into the former. Googling suggests the solution is accepting IntoIterator<Item = AsRef<str>>, which should be backwards compatible?

@jonhoo
Copy link
Owner

jonhoo commented Feb 12, 2022

Unfortunately this is harder than it sounds — we specifically need to get string references with a 'a lifetime in the methods in question so that we don't have to re-allocate and copy every string argument we're given. Notice how the code also uses 'a for the other arguments here:

tmp: &mut HashMap<Frame<'a>, FrameTime>,
frames: &mut Vec<TimedFrame<'a>>,

It would be nice to make the API work in such a way that the whole input doesn't need to be kept allocated across the runtime of the analysis, but it would require some deeper changes I think.

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

No branches or pull requests

2 participants