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
Refactor a List.generate to List.filled #87
Conversation
Bump min SDK to allow for-loop elements in collection literals.
I was originally going to write this with a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Worth an entry in the changelog?
...seems like this might could improve perf
Probably not, its possible but last I checked (recently) collection-for is still slower 🤷 |
I could do separators = List.filled(newParts.length + 1, style.separator);
if (!isAbsolute || newParts.isEmpty || !style.needsSeparator(root)) {
separators[0] = '';
} WDYT? |
To be clear, my primary goal is readability and I don't plan on spending time trying to microbenchmark this. Now that I wrote out this new |
I am fine with either version, I wouldn't focus on micro-benchmarking this. I just wanted to refute the idea that collection for is fast, cause it isn't today :D. |
No longer changing the min SDK so shouldn't be anything user visible. Likely does improve perf but I'm not going to bother benchmarking and I don't think it's worth calling out specifically in the changelog. |
The meaning is more clear without the indirection of a closure that
always returns the same value, and it will have better performance.
Also replace the
List.insert
by making the length longer to startwith and conditionally setting the first value.