Skip to content

Commit

Permalink
remove DATAPTR, #3301
Browse files Browse the repository at this point in the history
  • Loading branch information
jangorecki committed Feb 4, 2019
1 parent b351963 commit 3738443
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/fmelt.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,23 +441,23 @@ SEXP getvaluecols(SEXP DT, SEXP dtnames, Rboolean valfactor, Rboolean verbose, s
for (k=0; k<thislen; k++)
REAL(target)[counter + k] = REAL(thiscol)[INTEGER(thisidx)[k]-1];
} else {
memcpy((char *)DATAPTR(target)+j*data->nrow*size, (char *)DATAPTR(thiscol), data->nrow*size);
memcpy((char *)REAL(target)+j*data->nrow*size, (char *)REAL(thiscol), data->nrow*size);
}
break;
case INTSXP :
if (data->narm) {
for (k=0; k<thislen; k++)
INTEGER(target)[counter + k] = INTEGER(thiscol)[INTEGER(thisidx)[k]-1];
} else {
memcpy((char *)DATAPTR(target)+j*data->nrow*size, (char *)DATAPTR(thiscol), data->nrow*size);
memcpy((char *)INTEGER(target)+j*data->nrow*size, (char *)INTEGER(thiscol), data->nrow*size);
}
break;
case LGLSXP :
if (data->narm) {
for (k=0; k<thislen; k++)
LOGICAL(target)[counter + k] = LOGICAL(thiscol)[INTEGER(thisidx)[k]-1];
} else {
memcpy((char *)DATAPTR(target)+j*data->nrow*size, (char *)DATAPTR(thiscol), data->nrow*size);
memcpy((char *)LOGICAL(target)+j*data->nrow*size, (char *)LOGICAL(thiscol), data->nrow*size);
}
break;
default : error("Unknown column type '%s' for column '%s'.", type2char(TYPEOF(thiscol)), CHAR(STRING_ELT(dtnames, INTEGER(thisvaluecols)[i]-1)));
Expand Down Expand Up @@ -573,7 +573,7 @@ SEXP getidcols(SEXP DT, SEXP dtnames, Rboolean verbose, struct processData *data
}
} else {
for (j=0; j<data->lmax; j++)
memcpy((char *)DATAPTR(target)+j*data->nrow*size, (char *)DATAPTR(thiscol), data->nrow*size);
memcpy((char *)REAL(target)+j*data->nrow*size, (char *)REAL(thiscol), data->nrow*size);
}
break;
case INTSXP :
Expand All @@ -587,7 +587,7 @@ SEXP getidcols(SEXP DT, SEXP dtnames, Rboolean verbose, struct processData *data
}
} else {
for (j=0; j<data->lmax; j++)
memcpy((char *)DATAPTR(target)+j*data->nrow*size, (char *)DATAPTR(thiscol), data->nrow*size);
memcpy((char *)INTEGER(target)+j*data->nrow*size, (char *)INTEGER(thiscol), data->nrow*size);
}
break;
case LGLSXP :
Expand All @@ -601,7 +601,7 @@ SEXP getidcols(SEXP DT, SEXP dtnames, Rboolean verbose, struct processData *data
}
} else {
for (j=0; j<data->lmax; j++)
memcpy((char *)DATAPTR(target)+j*data->nrow*size, (char *)DATAPTR(thiscol), data->nrow*size);
memcpy((char *)LOGICAL(target)+j*data->nrow*size, (char *)LOGICAL(thiscol), data->nrow*size);
}
break;
case STRSXP :
Expand All @@ -618,7 +618,7 @@ SEXP getidcols(SEXP DT, SEXP dtnames, Rboolean verbose, struct processData *data
// From assign.c's memcrecycle - only one SET_STRING_ELT per RHS item is needed to set generations (overhead)
for (k=0; k<data->nrow; k++) SET_STRING_ELT(target, k, STRING_ELT(thiscol, k));
for (j=1; j<data->lmax; j++)
memcpy((char *)DATAPTR(target)+j*data->nrow*size, (char *)DATAPTR(target), data->nrow*size);
memcpy((char *)CHAR(target)+j*data->nrow*size, (char *)CHAR(target), data->nrow*size);
}
break;
case VECSXP :
Expand Down
4 changes: 2 additions & 2 deletions src/gsumm.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ SEXP gmedian(SEXP x, SEXP narm) {
isint64 = (isString(klass) && STRING_ELT(klass, 0) == char_integer64);
ans = PROTECT(allocVector(REALSXP, ngrp));
sub = PROTECT(allocVector(REALSXP, maxgrpn)); // allocate once upfront
ptr = DATAPTR(sub);
ptr = REAL(sub);
if (!LOGICAL(narm)[0]) {
for (i=0; i<ngrp; i++) {
isna = FALSE;
Expand Down Expand Up @@ -876,7 +876,7 @@ SEXP gmedian(SEXP x, SEXP narm) {
case LGLSXP: case INTSXP:
ans = PROTECT(allocVector(REALSXP, ngrp));
sub = PROTECT(allocVector(INTSXP, maxgrpn)); // allocate once upfront
ptr = DATAPTR(sub);
ptr = INTEGER(sub);
if (!LOGICAL(narm)[0]) {
for (i=0; i<ngrp; i++) {
isna = FALSE;
Expand Down
4 changes: 2 additions & 2 deletions src/rbindlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,8 @@ SEXP rbindlist(SEXP l, SEXP sexp_usenames, SEXP sexp_fill, SEXP idcol) {
case INTSXP:
case LGLSXP:
if (TYPEOF(thiscol) != TYPEOF(target)) error("Internal logical error in rbindlist.c, type of 'thiscol' should have already been coerced to 'target'. please report to data.table issue tracker.");
memcpy((char *)DATAPTR(target) + ansloc * SIZEOF(thiscol),
(char *)DATAPTR(thiscol),
memcpy((char *)LOGICAL(target) + ansloc * SIZEOF(thiscol),
(char *)LOGICAL(thiscol),
thislen * SIZEOF(thiscol));
break;
default :
Expand Down
2 changes: 1 addition & 1 deletion src/uniqlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ SEXP uniqlist(SEXP l, SEXP order)
}
} break;
case STRSXP : {
SEXP *vd=(SEXP *)DATAPTR(v), prev, elem; // TODO: tried to replace DATAPTR here but (SEXP *)&STRING_ELT(v,0) results in lvalue required as unary ‘&’ operand
SEXP *vd=(SEXP *)CHAR(v), prev, elem;
if (via_order) {
COMPARE1_VIA_ORDER && ENC2UTF8(elem)!=ENC2UTF8(prev) COMPARE2 // but most of the time they are equal, so ENC2UTF8 doesn't need to be called
} else {
Expand Down

0 comments on commit 3738443

Please sign in to comment.