-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
[Core] Add iteration support to Array
#86518
Conversation
dd6b35a
to
79705cd
Compare
I've been investigating an equivalent addition to |
79705cd
to
2c7a4de
Compare
Thanks, this looks great to me!
I think having only these few cases is fine, in fact, reviewing those changes is trickier (at least for me) than the added iterator code, so in my opinion "less is more" here :-) |
I think once we have added this to |
|
2c7a4de
to
bbbf572
Compare
bbbf572
to
9f70c97
Compare
9f70c97
to
e4eb3c2
Compare
e4eb3c2
to
cf03590
Compare
cf03590
to
3a11db6
Compare
3a11db6
to
64146cb
Compare
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.
This looks great to me!
I attempted to really scrutinize the changes to existing code to start using the iterator, and didn't notice anything that seemed like it would change behavior.
I'm not on the core team but decided to be bold and hit "approve" - I really want to be able to use this myself :-)
Thanks! |
Thank you! |
Added simple iteration support for
Array
, using the same method as the subscript operator, added the read-only part to the constant one as well as well for parity with that operatorMany, many, possible uses across the codebase but kept this restricted to a few cases, considering doing one of my sweeping PRs to improve use of
foreach
generally not just for this new addition, but will have to wait for right nowPut some of the methods in
variant.h
as they depend onVariant
being declared and wanted them to be inlineableNot tagging this as
Performance
as any improvement would be minimal, but it does, theoretically, carry a minor performance improvement as it avoids doing COW checks on each access, which would most of the time be a wasted check as theVector
is almost always not shared yet the mutation check is always performedWill squash the added cases once decided in case some additional "good to add" cases are suggested