Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/assign.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ closest I got to getting it to pass all tests :
setAttrib(x, SelfRefSymbol, p = R_MakeExternalPtr(
R_NilValue, // for identical() to return TRUE. identical() doesn't look at tag and prot
R_NilValue, //getAttrib(x, R_NamesSymbol), // to detect if names has been replaced and its tl lost, e.g. setattr(DT,"names",...)
PROTECT( // needed when --enable-strict-barrier it seems, iiuc. TO DO: test under that flag and remove if not needed.
PROTECT( // needed when --enable-strict-barrier it seems, iiuc. todo: test under that flag and remove if not needed.
env // wrap x in env to avoid an infinite loop in object.size() if prot=x were here
)
));
Expand Down Expand Up @@ -151,10 +151,10 @@ static SEXP shallow(SEXP dt, SEXP cols, R_len_t n)
// called from alloccol where n is checked carefully, or from shallow() at R level
// where n is set to truelength (i.e. a shallow copy only with no size change)
int protecti=0;
SEXP newdt = PROTECT(allocVector(VECSXP, n)); protecti++; // to do, use growVector here?
SEXP newdt = PROTECT(allocVector(VECSXP, n)); protecti++; // todo: use growVector here?
SHALLOW_DUPLICATE_ATTRIB(newdt, dt);

// TO DO: keepattr() would be faster, but can't because shallow isn't merely a shallow copy. It
// todo: keepattr() would be faster, but can't because shallow isn't merely a shallow copy. It
// also increases truelength. Perhaps make that distinction, then, and split out, but marked
// so that the next change knows to duplicate.
// keepattr() also merely points to the entire attributes list and thus doesn't allow replacing
Expand Down Expand Up @@ -256,7 +256,7 @@ SEXP alloccol(SEXP dt, R_len_t n, Rboolean verbose)
if (!selfrefok(dt,verbose))
return shallow(dt,R_NilValue,(n>l) ? n : l); // e.g. test 848 and 851 in R > 3.0.2
// added (n>l) ? ... for #970, see test 1481.
// TO DO: test realloc names if selfrefnamesok (users can setattr(x,"name") themselves for example.
// todo: test realloc names if selfrefnamesok (users can setattr(x,"name") themselves for example.
// if (TRUELENGTH(getAttrib(dt,R_NamesSymbol))!=tl)
// internal_error(__func__, "tl of dt passes checks, but tl of names (%d) != tl of dt (%d)", tl, TRUELENGTH(getAttrib(dt,R_NamesSymbol))); // # nocov

Expand Down Expand Up @@ -379,7 +379,7 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values)
if (rowsd[i]>=0) numToDo++;
}
if (verbose) Rprintf(_("Assigning to %d row subset of %d rows\n"), numToDo, nrow);
// TODO: include in message if any rows are assigned several times (e.g. by=.EACHI with dups in i)
// todo: include in message if any rows are assigned several times (e.g. by=.EACHI with dups in i)
if (numToDo==0) {
// isString(cols) is exclusive to calls from set()
if (!length(newcolnames) && !isString(cols)) {
Expand Down Expand Up @@ -509,7 +509,7 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values)
// modify DT by reference. Other than if new columns are being added and the allocVec() fails with
// out-of-memory. In that case the user will receive hard halt and know to rerun.
if (length(newcolnames)) {
oldtncol = TRUELENGTH(dt); // TO DO: oldtncol can be just called tl now, as we won't realloc here any more.
oldtncol = TRUELENGTH(dt); // todo: oldtncol can be just called tl now, as we won't realloc here any more.

if (oldtncol<oldncol) {
if (oldtncol==0) error(_("This data.table has either been loaded from disk (e.g. using readRDS()/load()) or constructed manually (e.g. using structure()). Please run setDT() or setalloccol() on it first (to pre-allocate space for new columns) before assigning by reference to it.")); // #2996
Expand Down Expand Up @@ -1260,7 +1260,7 @@ SEXP allocNAVector(SEXPTYPE type, R_len_t n)

SEXP allocNAVectorLike(SEXP x, R_len_t n) {
// writeNA needs the attribute retained to write NA_INTEGER64, #3723
// TODO: remove allocNAVector above when usage in fastmean.c, fcast.c and fmelt.c can be adjusted; see comments in PR3724
// todo: remove allocNAVector above when usage in fastmean.c, fcast.c and fmelt.c can be adjusted; see comments in PR3724
SEXP v = PROTECT(allocVector(TYPEOF(x), n));
copyMostAttrib(x, v);
writeNA(v, 0, n, false);
Expand Down
2 changes: 1 addition & 1 deletion src/between.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ SEXP between(SEXP x, SEXP lower, SEXP upper, SEXP incbounds, SEXP NAboundsArg, S
const SEXP *xp = STRING_PTR_RO(x);
#define LCMP (strcmp(CHAR(ENC2UTF8(l)),CHAR(ENC2UTF8(elem)))<=-open)
#define UCMP (strcmp(CHAR(ENC2UTF8(elem)),CHAR(ENC2UTF8(u)))<=-open)
// TODO if all ascii can be parallel, otherwise ENC2UTF8 could allocate
// todo: if all ascii can be parallel, otherwise ENC2UTF8 could allocate
if (check) for (int i=0; i<longestBound; ++i) {
const SEXP l=lp[i & lowMask], u=up[i & uppMask];
if (l!=NA_STRING && u!=NA_STRING && l!=u && strcmp(CHAR(ENC2UTF8(l)), CHAR(ENC2UTF8(u)))>0)
Expand Down
14 changes: 7 additions & 7 deletions src/bmerge.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ SEXP bmerge(SEXP idt, SEXP xdt, SEXP icolsArg, SEXP xcolsArg, SEXP xoArg, SEXP r
} else { // equi joins (or) non-equi join but no multiple matches
retFirstArg = PROTECT(allocVector(INTSXP, anslen));
retFirst = INTEGER(retFirstArg);
retLengthArg = PROTECT(allocVector(INTSXP, anslen)); // TODO: no need to allocate length at all when
retLengthArg = PROTECT(allocVector(INTSXP, anslen)); // todo: no need to allocate length at all when
retLength = INTEGER(retLengthArg); // mult = "first" / "last"
retIndexArg = PROTECT(allocVector(INTSXP, 0));
retIndex = INTEGER(retIndexArg);
Expand All @@ -162,7 +162,7 @@ SEXP bmerge(SEXP idt, SEXP xdt, SEXP icolsArg, SEXP xcolsArg, SEXP xoArg, SEXP r
// defaults need to populated here as bmerge_r may well not touch many locations, say if the last row of i is before the first row of x.
retFirst[j] = nomatch; // default to no match for NA goto below
}
// retLength[j] = 0; // TO DO: do this to save the branch below and later branches at R level to set .N to 0
// retLength[j] = 0; // todo: do this to save the branch below and later branches at R level to set .N to 0
int retLengthVal = (int)(nomatch != 0);
for (int j=0; j<anslen; j++)
retLength[j] = retLengthVal;
Expand Down Expand Up @@ -271,12 +271,12 @@ void bmerge_r(int xlowIn, int xuppIn, int ilowIn, int iuppIn, int col, int thisg
XVAL; \
if (CMP1) { /* relies on NA_INTEGER==INT_MIN, tested in init.c */ \
xlow=mid; \
} else if (CMP2) { /* TO DO: switch(sign(xval-ival)) ? */ \
} else if (CMP2) { /* todo: switch(sign(xval-ival)) ? */ \
xupp=mid; \
} else { \
/* xval == ival including NA_INTEGER==NA_INTEGER \
branch mid to find start and end of this group in this column \
TO DO?: not if mult=first|last and col<ncol-1 */ \
todo: not if mult=first|last and col<ncol-1 */ \
int tmplow = mid; \
while (tmplow<xupp-1) { \
int mid = tmplow + (xupp-tmplow)/2; \
Expand Down Expand Up @@ -341,7 +341,7 @@ void bmerge_r(int xlowIn, int xuppIn, int ilowIn, int iuppIn, int col, int thisg
} \
} \
int tmplow = lir; \
while (tmplow<iupp-1) { /* TO DO: could double up from lir rather than halving from iupp */ \
while (tmplow<iupp-1) { /* todo: could double up from lir rather than halving from iupp */ \
int mid = tmplow + (iupp-tmplow)/2; \
if (WRAP(icv[ o ? o[mid]-1 : mid ]) == IVAL) tmplow=mid; else iupp=mid; \
/* if we could guarantee ivals to be *always* sorted for all columns independently \
Expand Down Expand Up @@ -375,7 +375,7 @@ void bmerge_r(int xlowIn, int xuppIn, int ilowIn, int iuppIn, int col, int thisg
#define WRAP(x) (ENC2UTF8(x))
DO(int tmp=StrCmp(ENC2UTF8(xcv[XIND(mid)]), ival), tmp<0, tmp>0, int, 0, 0, ival)
// NA_STRING are allowed and joined to; does not do ENC2UTF8 again inside StrCmp
// TO DO: deal with mixed encodings and locale optionally; could StrCmp non-ascii in a thread-safe non-alloc manner
// todo: deal with mixed encodings and locale optionally; could StrCmp non-ascii in a thread-safe non-alloc manner
} break;
case REALSXP :
if (INHERITS(xc, char_integer64)) {
Expand All @@ -391,7 +391,7 @@ void bmerge_r(int xlowIn, int xuppIn, int ilowIn, int iuppIn, int col, int thisg
const double *icv = REAL(ic);
const double *xcv = REAL(xc);
const double ival = icv[ir];
const uint64_t ivalt = dtwiddle(ival); // TO: remove dtwiddle by dealing with NA, NaN, -Inf, +Inf up front
const uint64_t ivalt = dtwiddle(ival); // todo: remove dtwiddle by dealing with NA, NaN, -Inf, +Inf up front
#undef ISNAT
#undef WRAP
#define ISNAT(x) (ISNAN(x))
Expand Down
2 changes: 1 addition & 1 deletion src/data.table.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
// always be checked in UTF8 locale. This seems to be the best fix Arun could think of to put the encoding issues to rest.
// Since the if-statement will fail with the first condition check in "normal" ASCII cases, there shouldn't be huge penalty issues in
// most cases. Fix for #66, #69, #469 and #1293
// TODO: compare 1.9.6 performance with 1.9.7 with huge number of ASCII strings, and again after Jan 2018 when made macro.
// todo: compare 1.9.6 performance with 1.9.7 with huge number of ASCII strings, and again after Jan 2018 when made macro.
// Matt moved this to be macro in Jan 2018 so that branch can benefit from branch prediction too wherever used inside loops.
// This IS_ASCII will dereference s and that cache fetch is the part that may bite more than the branch, though. Without a call to
// to ENC2UTF as all, the pointer value can just be compared by the calling code without dereferencing it. It may still be worth
Expand Down
18 changes: 9 additions & 9 deletions src/dogroups.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
double nextTime = (showProgress) ? startTime+3 : 0; // wait 3 seconds before printing progress

defineVar(sym_BY, BY = PROTECT(allocVector(VECSXP, ngrpcols)), env); nprotect++; // PROTECT for rchk
SEXP bynames = PROTECT(allocVector(STRSXP, ngrpcols)); nprotect++; // TO DO: do we really need bynames, can we assign names afterwards in one step?
SEXP bynames = PROTECT(allocVector(STRSXP, ngrpcols)); nprotect++; // todo: do we really need bynames, can we assign names afterwards in one step?
for (int i=0; i<ngrpcols; ++i) {
int j = INTEGER(grpcols)[i]-1;
SET_VECTOR_ELT(BY, i, allocVector(TYPEOF(VECTOR_ELT(groups, j)),
nrowgroups ? 1 : 0)); // TODO: might be able to be 1 always but 0 when 'groups' are integer(0) seem sensible. #2440 was involved in the past.
nrowgroups ? 1 : 0)); // todo: might be able to be 1 always but 0 when 'groups' are integer(0) seem sensible. #2440 was involved in the past.
// Fix for #36, by cols with attributes when also used in `j` lost the attribute.
copyMostAttrib(VECTOR_ELT(groups, j), VECTOR_ELT(BY,i)); // not names, otherwise test 778 would fail
SET_STRING_ELT(bynames, i, STRING_ELT(getAttrib(groups,R_NamesSymbol), j));
Expand All @@ -109,7 +109,7 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
R_LockBinding(sym_BY, env);
if (isNull(jiscols) && (length(bynames)!=length(groups) || length(bynames)!=length(grpcols)))
error("!length(bynames)[%d]==length(groups)[%d]==length(grpcols)[%d]", length(bynames), length(groups), length(grpcols)); // # notranslate
// TO DO: check this check above.
// todo: check this check above.

N = PROTECT(findVar(install(".N"), env)); nprotect++; // PROTECT for rchk
SET_TRUELENGTH(N, -1); // marker for anySpecialStatic(); see its comments
Expand Down Expand Up @@ -183,7 +183,7 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
// Previously had replaced (i>0 || !isNull(lhs)) with i>0 to fix #49
// The above is now to fix #1993, see test 1746.
// In cases were no i rows match, '|| estn>-1' ensures that the last empty group creates an empty result.
// TODO: revisit and tidy
// todo: revisit and tidy

if (!isNull(lhs) &&
(istarts[i] == NA_INTEGER ||
Expand Down Expand Up @@ -227,7 +227,7 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
// Or in the words, this entire section, and this entire dogroups.c file, is now write-barrier compliant from v1.12.10
// and we hope that reference counting on by default from R 4.0 will avoid costly gc()s.
}
grpn = 1; // it may not be 1 e.g. test 722. TODO: revisit.
grpn = 1; // it may not be 1 e.g. test 722. todo: revisit.
SETLENGTH(I, grpn);
INTEGER(I)[0] = 0;
for (int j=0; j<length(xSD); ++j) {
Expand Down Expand Up @@ -361,7 +361,7 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
estn = 0;
for (int j=0; j<LENGTH(lens); ++j) estn+=ilens[j];
// Common case 2 : j returns as many rows as there are in the group (maybe a join)
// TO DO: this might over allocate if first group has 1 row and j is actually a single row aggregate
// todo: this might over allocate if first group has 1 row and j is actually a single row aggregate
// in cases when we're not sure could wait for the first few groups before deciding.
} else // maxn < grpn
estn = maxn * LENGTH(starts);
Expand Down Expand Up @@ -463,7 +463,7 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
if (firstalloc) {
nprotect++; // remember the first jval. If we UNPROTECTed now, we'd unprotect
firstalloc = FALSE; // ans. The first jval is needed to create the right size and type of ans.
// TO DO: could avoid this last 'if' by adding a dummy PROTECT after first alloc for this UNPROTECT(1) to do.
// todo: could avoid this last 'if' by adding a dummy PROTECT after first alloc for this UNPROTECT(1) to do.
}
else UNPROTECT(1); // the jval. Don't want them to build up. The first jval can stay protected till the end ok.
}
Expand All @@ -479,7 +479,7 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
if (verbose) Rprintf(_("Wrote less rows (%d) than allocated (%d).\n"),ansloc,LENGTH(VECTOR_ELT(ans,0)));
for (int j=0; j<length(ans); j++) SET_VECTOR_ELT(ans, j, growVector(VECTOR_ELT(ans,j), ansloc));
// shrinks (misuse of word 'grow') back to the rows written, otherwise leak until ...
// ... TO DO: set truelength to LENGTH(VECTOR_ELT(ans,0)), length to ansloc and enhance finalizer to handle over-allocated rows.
// ... todo: set truelength to LENGTH(VECTOR_ELT(ans,0)), length to ansloc and enhance finalizer to handle over-allocated rows.
}
} else ans = R_NilValue;
// Now reset length of .SD columns and .I to length of largest group, otherwise leak if the last group is smaller (often is).
Expand Down Expand Up @@ -533,7 +533,7 @@ SEXP growVector(SEXP x, const R_len_t newlen)
SEXP newx;
R_len_t len = length(x);
if (isNull(x)) error(_("growVector passed NULL"));
PROTECT(newx = allocVector(TYPEOF(x), newlen)); // TO DO: R_realloc(?) here?
PROTECT(newx = allocVector(TYPEOF(x), newlen)); // todo: R_realloc(?) here?
if (newlen < len) len=newlen; // i.e. shrink
if (!len) { // cannot memcpy invalid pointer, #6819
keepattr(newx, x);
Expand Down
2 changes: 1 addition & 1 deletion src/fastmean.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ SEXP fastmean(SEXP args)
break;
case REALSXP:
for (int i=0; i<l; ++i) {
if(ISNAN(REAL(x)[i])) continue; // TO DO: could drop this line and let NA propagate?
if(ISNAN(REAL(x)[i])) continue; // todo: could drop this line and let NA propagate?
s += REAL(x)[i];
n++;
}
Expand Down
4 changes: 2 additions & 2 deletions src/fcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// #include <signal.h> // the debugging machinery + breakpoint aidee
// raise(SIGINT);

// TO DO: margins
// todo: margins
SEXP fcast(SEXP lhs, SEXP val, SEXP nrowArg, SEXP ncolArg, SEXP idxArg, SEXP fill, SEXP fill_d, SEXP is_agg, SEXP some_fillArg) {
int nrows=INTEGER(nrowArg)[0], ncols=INTEGER(ncolArg)[0];
int nlhs=length(lhs), nval=length(val), *idx = INTEGER(idxArg);
Expand Down Expand Up @@ -127,7 +127,7 @@ SEXP fcast(SEXP lhs, SEXP val, SEXP nrowArg, SEXP ncolArg, SEXP idxArg, SEXP fil
// if (TYPEOF(env) != ENVSXP) error(_("Argument 'env' to (data.table internals) 'cast_order' must be an environment"));
// if (TYPEOF(v) == VECSXP) len = length(VECTOR_ELT(v, 0));
// else len = length(v);
// PROTECT(call = lang2(install("forder"), v)); // TODO: save the 'eval' by calling directly the C-function.
// PROTECT(call = lang2(install("forder"), v)); // todo: save the 'eval' by calling directly the C-function.
// ans = PROTECT(eval(call, env));
// if (length(ans) == 0) { // forder returns integer(0) if already sorted
// UNPROTECT(1); // ans
Expand Down
Loading
Loading