-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Tests for GenericAppendOnlyBuffer move operations added. #37667
Tests for GenericAppendOnlyBuffer move operations added. #37667
Conversation
28f856b
to
ff5d09d
Compare
PR #37667: Size comparison from 8464e5f to ff5d09d Full report (64 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, tizen)
|
ff5d09d
to
92c1e30
Compare
PR #37667: Size comparison from 7dccded to 92c1e30 Full report (73 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
92c1e30
to
b909826
Compare
b909826
to
589f7f3
Compare
PR #37667: Size comparison from 5398152 to 589f7f3 Full report (73 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
list.Append(12); | ||
|
||
// Get a ListBuilder base class object | ||
GenericAppendOnlyBuffer originalBuffer{ static_cast<GenericAppendOnlyBuffer &&>(std::move(list)) }; |
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 static cast should not be needed, as it is what std::move
does.
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.
I can try removing it. But list's type is not GenericAppendOnlyBuffer
but ListBuilder<int>
which in turn derives from GenericAppendOnlyBuffer
.
if I'm not mistaken, std::move(list) will cast a ListBuilder<int> &
into a ListBuilder<int> &&
, and then I still need to go from ListBuilder<int> &&
to GenericAppendOnlyBuffer &&
, and that's why static_cast is used here.
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.
You should have listbuilder support the move constructor and that would in turn move the append-only. If listbuilder has no move suport, that sounds like a bug.
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.
please disregard this PR in favor of this new one: #37812
I had to recreate my environment so it was much easier to create a new branch with the existing commits.
ASSERT_EQ(originalBuffer.Size(), size_t{ 0 }); // NOLINT(bugprone-use-after-move) | ||
ASSERT_TRUE(originalBuffer.IsEmpty()); // NOLINT(bugprone-use-after-move) |
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 seems like a conceited test that does something we should not expect.
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.
here I was following @andreilitvin suggestion to assert original buffer (the one instance being moved from) gets its (observable) internal state cleared.
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.
please disregard this PR in favor of this new one: #37812
I had to recreate my environment so it was much easier to create a new branch with the existing commits.
list2.Append(21); | ||
|
||
// Get a ListBuilder base class object | ||
GenericAppendOnlyBuffer originalBuffer{ static_cast<GenericAppendOnlyBuffer &&>(std::move(list1)) }; |
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.
Remove all static cast to &&
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.
please disregard this PR in favor of this new one: #37812
I had to recreate my environment so it was much easier to create a new branch with the existing commits.
/gemini review |
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.
Code Review
The code changes introduce a new test case for GenericAppendOnlyBuffer
move operations. The implementation is generally well-done, but I've left a few suggestions for improvement.
Summary of Findings
- Clarity of comments: The comment "move constructor called for the second time here" could be more precise. It's not immediately clear why it's the 'second time'. Consider rephrasing for better understanding.
- Consistency in naming: Consider renaming
list1
andlist2
tolist
andanotherList
respectively, for consistency with the first test case and improved readability.
Assessment
The pull request introduces a new test case for GenericAppendOnlyBuffer
move operations, which is a valuable addition to ensure the correctness of the data model provider. The implementation appears to be well-structured and covers both move construction and move assignment scenarios. However, there are a few minor points that could be improved for clarity and consistency. I would recommend addressing these comments before requesting a review from someone else, but feel free to request another review from Gemini via /gemini review
when you have addressed these comments and I'll take another look! Note that I am not authorized to directly approve the pull request, and users should have others review and approve this code before merging.
@andy31415, @tcarmelveilleux please review this other one instead: closing this one. |
Fixes #37223
Testing
new
TEST_F(TestMetadataList, BufferMoveOperationsWork)
added intosrc/app/data-model-provider/tests/TestMetadataList.cpp