-
Notifications
You must be signed in to change notification settings - Fork 197
Don't iterate iterable arguments twice in PbList #1070
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
Conversation
|
@rakudrama I can't add you as a reviewer, could you also have a look? |
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
|
With all the branching testing this becomes a quarter long engineering effort.. We need to test all combinations of: (1) when the iterable is a: PbList, List, and other Note that error conditions are already not tested today, I wouldn't be surprised if error checking is different based on the check function and argument type today. I'm inclined to do the simplest possible thing here at the cost of performance. Use a |
|
@sigurdm all internal downstream breakage has been fixed and this is ready for merging now. I think @rakudrama is away this week so he won't be reviewing it. I didn't address the @rakudrama's comments (I did, but then reverted the changes). The reason is because there are just too many special cases if we want to do the most performant way possible in all possible ways of calling these methods, and all those special cases will need to be tested too. It's also very tricky to not have different exception behavior when e.g. the argument is a We can improve performance of these methods as needed. Note that the performance does not change when the check function is not available, and I think even with the check function the impact may be negligible. For example, compare before and after: When the check function is not available they're the same. When it's available, the old version already iterates once with So I suspect the new code performance should not be too bad (maybe even better) than the old one because the new code iterates once, and the old code already iterated using |
Update
PbListmethods that update the list with anIterableargument toavoid iterating the iterable twice: once for checking the element validity and
once again for actually adding the values.
Methods updated:
Exception handling behavior before this PR was undefined (same as the standard
library
List), and it's slightly changed with this PR:addAll: previously if the iterator throws the list was left unchanged, now
the elements until the exception will be added.
Other methods: exception behaviors are now the same as the standard library
Listmethods.It's hard to tell whether the previous behavior was the same or different
with the standard library
Listmethods, as the exception behavior of thoseare undefined.
To avoid allocating new iterators when a check function is not available, we
have conditionals in each of these methods and call the standard library
Listmethods directly when there isn't a check function.
To avoid increasing number of cases needed to be tested, we don't special case
iterable types like
PbListandListin these methods. When the checkfunction is available we simply
mapthem with the check function. Otherwisecall the same method on
wrappedListdirectly.Fixes #730.
cl/823443311