From 33426569637455d48bc554b9573806d251839036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Fri, 12 Jul 2024 11:04:46 +0200 Subject: [PATCH] Use LOGICAL_RO() instead of LOGICAL() in copyVector() to avoid ALTREP materialization --- src/main/duplicate.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/duplicate.c b/src/main/duplicate.c index 9c78294a736..4ce12e19d78 100644 --- a/src/main/duplicate.c +++ b/src/main/duplicate.c @@ -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); @@ -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++) \