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
Add coders for std::array and WTF::EnumeratedArray #5668
Conversation
EWS run on current version of this PR (hash b903808) |
// We add 1 to the size because we expect that LastValue is the maximum value of the enum, | ||
// rather than the count of items in the enum. | ||
// We're assuming the values in the enum are zero-indexed. |
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.
Is this comment not useful?
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.
The fact that we assume the values are zero-based, and that LastValue is indeed the last value and not one past the last value, are already mentioned in the comment at the top of the class, a few lines up. I think the explanation of why we need to add 1 is reasonably self-evident, but I'm happy to leave it in if you prefer.
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.
Up to you. I'm the author of that comment so I think I'm biased :P
{ | ||
std::array<std::optional<T>, size> items; | ||
|
||
for (auto& item : items) { |
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.
Hey, that's nifty. The caller indicates how many items they expect, so there isn't a need to send the size across the wire.
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.
Yes, it's encoded in the type itself.
https://bugs.webkit.org/show_bug.cgi?id=246898 <rdar://problem/101453146> Reviewed by Myles C. Maxfield. * Source/WTF/wtf/EnumeratedArray.h: * Source/WTF/wtf/Forward.h: * Source/WebKit/Platform/IPC/ArgumentCoders.h: Canonical link: https://commits.webkit.org/255901@main
b903808
to
10f809a
Compare
Committed 255901@main (10f809a): https://commits.webkit.org/255901@main Reviewed commits have been landed. Closing PR #5668 and removing active labels. |
10f809a
b903808