Skip to content
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

Use LOGICAL_RO() instead of LOGICAL() in copyVector() to avoid ALTREP materialization #169

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
12 changes: 6 additions & 6 deletions src/main/duplicate.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,23 +382,23 @@ void copyVector(SEXP s, SEXP t)
xcopyStringWithRecycle(s, t, 0, ns, nt);
break;
case LGLSXP:
xcopyLogicalWithRecycle(LOGICAL(s), LOGICAL(t), 0, ns, nt);
xcopyLogicalWithRecycle(LOGICAL(s), LOGICAL_RO(t), 0, ns, nt);
break;
case INTSXP:
xcopyIntegerWithRecycle(INTEGER(s), INTEGER(t), 0, ns, nt);
xcopyIntegerWithRecycle(INTEGER(s), INTEGER_RO(t), 0, ns, nt);
break;
case REALSXP:
xcopyRealWithRecycle(REAL(s), REAL(t), 0, ns, nt);
xcopyRealWithRecycle(REAL(s), REAL_RO(t), 0, ns, nt);
break;
case CPLXSXP:
xcopyComplexWithRecycle(COMPLEX(s), COMPLEX(t), 0, ns, nt);
xcopyComplexWithRecycle(COMPLEX(s), COMPLEX_RO(t), 0, ns, nt);
break;
case EXPRSXP:
case VECSXP:
xcopyVectorWithRecycle(s, t, 0, ns, nt);
break;
case RAWSXP:
xcopyRawWithRecycle(RAW(s), RAW(t), 0, ns, nt);
xcopyRawWithRecycle(RAW(s), RAW_RO(t), 0, ns, nt);
break;
default:
UNIMPLEMENTED_TYPE("copyVector", s);
Expand Down Expand Up @@ -486,7 +486,7 @@ void copyMatrix(SEXP s, SEXP t, Rboolean byrow)

#define COPY_WITH_RECYCLE(VALTYPE, TNAME) \
attribute_hidden void \
xcopy##TNAME##WithRecycle(VALTYPE *dst, VALTYPE *src, R_xlen_t dstart, R_xlen_t n, R_xlen_t nsrc) { \
xcopy##TNAME##WithRecycle(VALTYPE *dst, const VALTYPE *src, R_xlen_t dstart, R_xlen_t n, R_xlen_t nsrc) { \
\
if (nsrc >= n) { /* no recycle needed */ \
for(R_xlen_t i = 0; i < n; i++) \
Expand Down
10 changes: 5 additions & 5 deletions src/main/duplicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ Iterator macro to fill a matrix from a vector with re-use of vector
(sidx >= nsrc) ? sidx -= nsrc : 0, \
didx += drows)

void xcopyComplexWithRecycle(Rcomplex *dst, Rcomplex *src, R_xlen_t dstart, R_xlen_t n, R_xlen_t nsrc);
void xcopyIntegerWithRecycle(int *dst, int *src, R_xlen_t dstart, R_xlen_t n, R_xlen_t nsrc);
void xcopyLogicalWithRecycle(int *dst, int *src, R_xlen_t dstart, R_xlen_t n, R_xlen_t nsrc);
void xcopyRawWithRecycle(Rbyte *dst, Rbyte *src, R_xlen_t dstart, R_xlen_t n, R_xlen_t nsrc);
void xcopyRealWithRecycle(double *dst, double *src, R_xlen_t dstart, R_xlen_t n, R_xlen_t nsrc);
void xcopyComplexWithRecycle(Rcomplex *dst, const Rcomplex *src, R_xlen_t dstart, R_xlen_t n, R_xlen_t nsrc);
void xcopyIntegerWithRecycle(int *dst, const int *src, R_xlen_t dstart, R_xlen_t n, R_xlen_t nsrc);
void xcopyLogicalWithRecycle(int *dst, const int *src, R_xlen_t dstart, R_xlen_t n, R_xlen_t nsrc);
void xcopyRawWithRecycle(Rbyte *dst, const Rbyte *src, R_xlen_t dstart, R_xlen_t n, R_xlen_t nsrc);
void xcopyRealWithRecycle(double *dst, const double *src, R_xlen_t dstart, R_xlen_t n, R_xlen_t nsrc);
void xcopyStringWithRecycle(SEXP dst, SEXP src, R_xlen_t dstart, R_xlen_t n, R_xlen_t nsrc);
void xcopyVectorWithRecycle(SEXP dst, SEXP src, R_xlen_t dstart, R_xlen_t n, R_xlen_t nsrc);

Expand Down
Loading