-
Notifications
You must be signed in to change notification settings - Fork 508
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
RSValue array cleanup - [MOD-7145] #4612
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4612 +/- ##
==========================================
- Coverage 86.26% 86.25% -0.02%
==========================================
Files 190 190
Lines 34847 34828 -19
==========================================
- Hits 30061 30040 -21
- Misses 4786 4788 +2 ☔ View full report in Codecov by Sentry. |
* Helper function to allocate memory before passing it to RSValue_NewArray | ||
*/ | ||
static inline RSValue **RSValue_AllocateArray(uint32_t len) { | ||
return (RSValue **)rm_malloc(len * sizeof(RSValue *)); |
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.
calloc :)
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.
Don’t we care about the performance difference? In all the places we fill the entire array anyway. This is not a partially initialized struct but an array of pointers.
I added a memset
call in the only place we might not fill the array (and in this case it also most likely a but in the trieMap or its iterator
Describe the changes in the pull request
Remove unnecessary initialization and branching, as we almost exclusively were calling
RSValue_NewArrayEx(arr, len, RSVAL_ARRAY_NOINCREF | RSVAL_ARRAY_ALLOC);
(with these flags), and in the few cases we don't we can get the same behavior with minor adjustments.We can then delete
RSValue_NewArrayEx
and useRSValue_NewArray
that gives the same behavior as the prior call with the commonly used flags, without branching and no-op loopsMark if applicable