Skip to content

Commit 1c05f11

Browse files
use getVar over findVar (#7575)
1 parent 63dec52 commit 1c05f11

3 files changed

Lines changed: 17 additions & 7 deletions

File tree

NEWS.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@
66

77
### Notes
88

9-
1. Removed use of non-API macros `ATTRIB`, `SET_ATTRIB`, [#6180](https://github.com/Rdatatable/data.table/issues/6180). Thanks @aitap for the continued assiduous work here.
9+
1. Removed use of non-API `ATTRIB`, `SET_ATTRIB`, and `findVar` [#6180](https://github.com/Rdatatable/data.table/issues/6180). Thanks @aitap for the continued assiduous work here, and @MichaelChirico for the easy fix to replace `findVar` with `R_getVar`.
10+
11+
### Notes
12+
13+
1. {data.table} now depends on R 3.5.0 (2018).
14+
15+
2. pydatatable compatibility layer in `fread()` and `fwrite()` has been removed, [#7069](https://github.com/Rdatatable/data.table/issues/7069). Thanks @badasahog for the report and the PR.
16+
17+
3. Vignettes are now built using `litedown` instead of `knitr`, [#6394](https://github.com/Rdatatable/data.table/issues/6394). Thanks @jangorecki for the suggestion and @ben-schwen and @aitap for the implementation.
18+
1019

1120
## data.table [v1.18.0](https://github.com/Rdatatable/data.table/milestone/37?closed=1) 23 December 2025
1221

src/data.table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# define LOGICAL_RO LOGICAL
1515
#endif
1616
#if R_VERSION < R_Version(4, 5, 0)
17+
# define R_getVar(x, env, inherits) findVar(x, env)
1718
# define isDataFrame(x) isFrame(x) // #6180
1819
# define CLEAR_ATTRIB(x) SET_ATTRIB(x, R_NilValue)
1920
# define ANY_ATTRIB(x) (!(isNull(ATTRIB(x))))

src/dogroups.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
9595
ngrpcols = length(grpcols);
9696
nrowgroups = length(VECTOR_ELT(groups,0));
9797
// fix for longstanding FR/bug, #495. E.g., DT[, c(sum(v1), lapply(.SD, mean)), by=grp, .SDcols=v2:v3] resulted in error.. the idea is, 1) we create .SDall, which is normally == .SD. But if extra vars are detected in jexp other than .SD, then .SD becomes a shallow copy of .SDall with only .SDcols in .SD. Since internally, we don't make a copy, changing .SDall will reflect in .SD. Hopefully this'll workout :-).
98-
SEXP SDall = PROTECT(findVar(install(".SDall"), env)); nprotect++; // PROTECT for rchk
99-
SEXP SD = PROTECT(findVar(install(".SD"), env)); nprotect++;
98+
SEXP SDall = PROTECT(R_getVar(install(".SDall"), env, false)); nprotect++; // PROTECT for rchk
99+
SEXP SD = PROTECT(R_getVar(install(".SD"), env, false)); nprotect++;
100100

101101
const bool showProgress = LOGICAL(showProgressArg)[0]==1 && ngrp > 1; // showProgress only if more than 1 group
102102
double startTime = (showProgress) ? wallclock() : 0; // For progress printing, startTime is set at the beginning
@@ -125,12 +125,12 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
125125
error("!length(bynames)[%d]==length(groups)[%d]==length(grpcols)[%d]", length(bynames), length(groups), length(grpcols)); // # notranslate
126126
// TO DO: check this check above.
127127

128-
N = PROTECT(findVar(install(".N"), env)); nprotect++; // PROTECT for rchk
128+
N = PROTECT(R_getVar(install(".N"), env, false)); nprotect++; // PROTECT for rchk
129129
hash_set(specials, N, -1); // marker for anySpecialStatic(); see its comments
130-
GRP = PROTECT(findVar(install(".GRP"), env)); nprotect++;
130+
GRP = PROTECT(R_getVar(install(".GRP"), env, false)); nprotect++;
131131
hash_set(specials, GRP, -1); // marker for anySpecialStatic(); see its comments
132-
iSD = PROTECT(findVar(install(".iSD"), env)); nprotect++; // 1-row and possibly no cols (if no i variables are used via JIS)
133-
xSD = PROTECT(findVar(install(".xSD"), env)); nprotect++;
132+
iSD = PROTECT(R_getVar(install(".iSD"), env, false)); nprotect++; // 1-row and possibly no cols (if no i variables are used via JIS)
133+
xSD = PROTECT(R_getVar(install(".xSD"), env, false)); nprotect++;
134134
R_len_t maxGrpSize = 0;
135135
const int *ilens = INTEGER(lens), n=LENGTH(lens);
136136
for (R_len_t i=0; i<n; ++i) {

0 commit comments

Comments
 (0)