-
Notifications
You must be signed in to change notification settings - Fork 1k
Migrate most uses of SETLENGTH to the resizable API
#7451
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
base: master
Are you sure you want to change the base?
Changes from all commits
23c7b3b
c3e8f0c
04437b6
2fa7728
332bfba
be921b1
c1c4f76
87315a4
2dd68e8
7395eb1
40b92d1
af91fe9
5caf9cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,6 +87,22 @@ | |
| # endif | ||
| #endif | ||
|
|
||
| // TODO(R>=4.6.0): remove the SVN revision check | ||
| #if R_VERSION < R_Version(4, 6, 0) || R_SVN_REVISION < 89077 | ||
| # define R_allocResizableVector(type, maxlen) R_allocResizableVector_(type, maxlen) | ||
| # define R_duplicateAsResizable(x) R_duplicateAsResizable_(x) | ||
| # define R_resizeVector(x, newlen) SETLENGTH(x, newlen) | ||
| # define R_maxLength(x) R_maxLength_(x) | ||
| static inline R_xlen_t R_maxLength_(SEXP x) { | ||
| return IS_GROWABLE(x) ? TRUELENGTH(x) : XLENGTH(x); | ||
| } | ||
| # define R_isResizable(x) R_isResizable_(x) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need if (ALTREP(x)) return false;
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. We also checked for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could also teach |
||
| static inline bool R_isResizable_(SEXP x) { | ||
| // IS_GROWABLE also checks for XLENGTH < TRUELENGTH | ||
| return (LEVELS(x) & 0x20) && TRUELENGTH(x); | ||
| } | ||
| #endif | ||
|
|
||
| // init.c | ||
| extern SEXP char_integer64; | ||
| extern SEXP char_ITime; | ||
|
|
@@ -282,7 +298,7 @@ SEXP memcpyVector(SEXP dest, SEXP src, SEXP offset, SEXP size); | |
| SEXP memcpyDT(SEXP dest, SEXP src, SEXP offset, SEXP size); | ||
| SEXP memcpyVectoradaptive(SEXP dest, SEXP src, SEXP offset, SEXP size); | ||
| SEXP memcpyDTadaptive(SEXP dest, SEXP src, SEXP offset, SEXP size); | ||
| SEXP setgrowable(SEXP x); | ||
| SEXP copyAsGrowable(SEXP x, SEXP by_column); | ||
|
|
||
| // nafill.c | ||
| void nafillDouble(double *x, uint_fast64_t nx, unsigned int type, double fill, bool nan_is_na, ans_t *ans, bool verbose); | ||
|
|
@@ -322,6 +338,8 @@ bool perhapsDataTable(SEXP x); | |
| SEXP perhapsDataTableR(SEXP x); | ||
| SEXP frev(SEXP x, SEXP copyArg); | ||
| NORET void internal_error(const char *call_name, const char *format, ...); | ||
| SEXP R_allocResizableVector_(SEXPTYPE type, R_xlen_t maxlen); | ||
| SEXP R_duplicateAsResizable_(SEXP x); | ||
|
|
||
| // types.c | ||
| char *end(char *start); | ||
|
|
||
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.
Should this be guarded by
R_isResizable_(x)andnew_len <= TRUELENGTH(x), and no attributes?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 would be cleaner to guard for them, so we not only catch them via R-devels runner
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 don't think we should introduce extra checks here, this is called in tight loops, and it is better to check before those loops.
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.
What's a better benchmark for this,
frollapply(adaptive = TRUE), orfoo[bar, by = baz]?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.
frolladaptive willa stress more, unless grouping is by unique column, then probably similarly