Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Looks like this part is actually coming all the way from mono/mono GArray that have similar behavior, https://github.com/dotnet/runtime/blob/main/src/mono/mono/eglib/garray.c#L229.
Since this follow the std::vector::resize, https://en.cppreference.com/w/cpp/container/vector/resize, it should behave accordingly, so if new size == current size do nothing, new size smaller than current size, reduce elements, if new size is bigger than current size, it should grow to requested size and setup values to default.
if (size > vector->_internal._capacity) is an optimization to not call additional function in case not really needed (there is already capacity available in the vector), so that works, and the shrink scenario already checks against vector->size, so that is also fine.
Could you please add a test case for this scenario in https://github.com/dotnet/runtime/blob/main/src/mono/mono/eventpipe/test/dn-vector-tests.c#L945 as well? It should be possible to build and run these tests locally, enabling this when building Mono runtime, https://github.com/dotnet/runtime/blob/main/src/mono/mono/eventpipe/test/CMakeLists.txt, by setting ENABLE_EVENTPIPE_TEST, that should produce a test executable that runs all tests. NOTE, there might be tests broken in that suite, since it is currently run manual, and I guess not for sometime, but is normally straight forward to fix, please let me know if you have issues with the test suite.
Uh oh!
There was an error while loading. Please reload this page.
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.
It is also worth pointing out that this function is currently not used in the dotnet runtime codebase. @srxqds do you use the library for standalone implementation or using it in Mono runtime embedding scenarios?
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.
ok,I have another fix, I will upload all later