-
Notifications
You must be signed in to change notification settings - Fork 1k
set(): only reallocate the table if resizing would fail otherwise
#7606
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7606 +/- ##
==========================================
+ Coverage 99.01% 99.02% +0.01%
==========================================
Files 87 87
Lines 16896 16903 +7
==========================================
+ Hits 16730 16739 +9
+ Misses 166 164 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
No obvious timing issues in HEAD=fix-7604 Generated via commit 599f1cb Download link for the artifact containing the test results: ↓ atime-results.zip
|
|
Did we want to include this in 1.18.2 as well? |
Co-authored-by: Michael Chirico <chiricom@google.com>
Co-Authored-By: Michael Chirico <michaelchirico4@gmail.com>
R/data.table.R
Outdated
| # when removing a column, value can be NULL or list with NULLs inside | ||
| removing = is.null(value) || (is.list(value) && length(value) == length(j) && any(vapply_1b(value, is.null))) | ||
| # columns can be created by name | ||
| adding = is.character(j) && !all(j %chin% names(x)) |
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.
should we caching the result of j %chin% names(x) here?
ben-schwen
left a comment
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.
LGTM, TY!
Co-Authored-By: Benjamin Schwendinger <52290390+ben-schwen@users.noreply.github.com
|
Shouldn't need a NEWS item as a follow-up to #7538. |
…7606) * Regression tests * set(): only reallocate if resizing would fail * Update R/data.table.R Co-authored-by: Michael Chirico <chiricom@google.com> * Rename test variables Co-Authored-By: Michael Chirico <michaelchirico4@gmail.com> * Cache j %chin% names(x) Co-Authored-By: Benjamin Schwendinger <52290390+ben-schwen@users.noreply.github.com --------- Co-authored-by: Michael Chirico <chiricom@google.com> Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>

In particular, do not reallocate when changing existing columns without resizing the table. Reallocating and reassigning the table in the caller misses the cases when the table is shared outside the caller's frame (e.g. the caller's caller).
Fixes: #7604