Skip to content

Commit

Permalink
Small correction
Browse files Browse the repository at this point in the history
  • Loading branch information
2005m committed Jun 25, 2024
1 parent 445833c commit 1a0bf42
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
6 changes: 3 additions & 3 deletions MD5
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ a52426250b954a335b1121948e057ee7 *src/Makevars.in
95e3011e37d9dde0d75f3a3819b2acd3 *src/Makevars.win
1e8b11cf04b116653c0a82a20f72490b *src/nswitch.c
7b6cc295ee89e397e47957097cf15417 *src/psort.c
d9e5ee62440914d68cec114cd9717af2 *src/psum.c
8c15e9c171d447aed088cec849323fab *src/psum.c
7589054d8388fe7ed3354a5aa388eb02 *src/share.c
ef9329d7e748c13b9526fca1788a1891 *src/topn.c
8b27a6955a60f8c94b6ae39845948bb9 *src/utils.c
ffd709a7cfedf05d54c7577f8a248a28 *src/vswitch.c
58a06280212a06ea2b8039bebb03fcdf *src/utils.c
37787d47d80dfd40bc3d12699ed30441 *src/vswitch.c
6af1b66c0c90f6809c960e2133c1b5e4 *tests/test_kit.R
0dce9bd953fe40b1c8fae3d01a597e7c *tests/test_kit.Rout.save
4 changes: 2 additions & 2 deletions src/psum.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,14 +950,14 @@ SEXP pfirstR(SEXP last, SEXP args) {
}
} break;
case STRSXP: {
SEXP *restrict pans = STRING_PTR_RO(ans);
const SEXP *restrict pans = STRING_PTR_RO(ans);
for (int i = 1; i < n; ++i) {
const SEXP *restrict pa = STRING_PTR_RO(PTR_ETL(args, i));
ssize_t nna = 0;
for (ssize_t j = 0; j < len0; ++j) {
if(pans[j] == NA_STRING) {
if(pa[j] == NA_STRING) ++nna;
else pans[j] = pa[j];
else SET_STRING_ELT(ans, j, pa[j]);
}
}
if(nna == 0) break;
Expand Down
7 changes: 3 additions & 4 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,8 @@ SEXP subSetRowDataFrame(SEXP df, SEXP rws) {
case STRSXP : {
const SEXP *restrict ptmp = STRING_PTR_RO(pdf[i]);
SEXP TYPECOL = PROTECT(allocVector(STRSXP, len_rws));
SEXP *restrict pc = STRING_PTR_RO(TYPECOL);
for (R_xlen_t j = 0; j < len_rws; ++j) {
pc[j] = ptmp[prws[j]];
SET_STRING_ELT(TYPECOL,j, ptmp[prws[j]]);
}
copyMostAttrib(pdf[i], TYPECOL);
SET_VECTOR_ELT(dfo, i, TYPECOL);
Expand Down Expand Up @@ -812,7 +811,7 @@ SEXP dfToMatrix(SEXP df) {

bool isMixEnc(SEXP x) {
const R_xlen_t len = xlength(x);
SEXP *px = STRING_PTR_RO(x);
const SEXP *px = STRING_PTR_RO(x);
const cetype_t ces = getCharCE(px[0]);
for (R_xlen_t i = 1; i < len; ++i)
if(getCharCE(px[i]) != ces)
Expand All @@ -821,7 +820,7 @@ bool isMixEnc(SEXP x) {
}

SEXP enc2UTF8(SEXP x) {
SEXP *px = STRING_PTR_RO(x);
const SEXP *px = STRING_PTR_RO(x);
const R_xlen_t len = xlength(x);
if (getCharCE(px[0]) != CE_UTF8) {
SEXP ans = PROTECT(allocVector(STRSXP, len));
Expand Down
12 changes: 6 additions & 6 deletions src/vswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ SEXP vswitchR(SEXP x, SEXP values, SEXP outputs, SEXP na, SEXP nthreads, SEXP ch
const int *restrict px = LOGICAL(x);
const int *restrict pvalues = LOGICAL(values);
for (ssize_t i=0; i<len_values; ++i) {
SEXP *ppo = STRING_PTR_RO(po[i]);
const SEXP *ppo = STRING_PTR_RO(po[i]);
for (ssize_t j=0; j<len_x; ++j) {
if (px[j]==pvalues[i]) {
SET_STRING_ELT(ans, j, ppo[j & amask[i]]);
Expand All @@ -526,7 +526,7 @@ SEXP vswitchR(SEXP x, SEXP values, SEXP outputs, SEXP na, SEXP nthreads, SEXP ch
const int *restrict px = INTEGER(x);
const int *restrict pvalues = INTEGER(values);
for (ssize_t i=0; i<len_values; ++i) {
SEXP *ppo = STRING_PTR_RO(po[i]);
const SEXP *ppo = STRING_PTR_RO(po[i]);
for (ssize_t j=0; j<len_x; ++j) {
if (px[j]==pvalues[i]) {
SET_STRING_ELT(ans, j, ppo[j & amask[i]]);
Expand All @@ -538,7 +538,7 @@ SEXP vswitchR(SEXP x, SEXP values, SEXP outputs, SEXP na, SEXP nthreads, SEXP ch
const double *restrict px = REAL(x);
const double *restrict pvalues = REAL(values);
for (ssize_t i=0; i<len_values; ++i) {
SEXP *ppo = STRING_PTR_RO(po[i]);
const SEXP *ppo = STRING_PTR_RO(po[i]);
for (ssize_t j=0; j<len_x; ++j) {
if (px[j]==pvalues[i]) {
SET_STRING_ELT(ans, j, ppo[j & amask[i]]);
Expand All @@ -550,7 +550,7 @@ SEXP vswitchR(SEXP x, SEXP values, SEXP outputs, SEXP na, SEXP nthreads, SEXP ch
const Rcomplex *restrict px = COMPLEX(x);
const Rcomplex *restrict pvalues = COMPLEX(values);
for (ssize_t i=0; i<len_values; ++i) {
SEXP *ppo = STRING_PTR_RO(po[i]);
const SEXP *ppo = STRING_PTR_RO(po[i]);
for (ssize_t j=0; j<len_x; ++j) {
if (EQUAL_CPLX(px[j],pvalues[i])) {
SET_STRING_ELT(ans, j, ppo[j & amask[i]]);
Expand All @@ -562,7 +562,7 @@ SEXP vswitchR(SEXP x, SEXP values, SEXP outputs, SEXP na, SEXP nthreads, SEXP ch
const SEXP *restrict px = STRING_PTR_RO(utfcon ? xans : x);
const SEXP *restrict pvalues = STRING_PTR_RO(utfcon ? vans : values);
for (ssize_t i=0; i<len_values; ++i) {
SEXP *ppo = STRING_PTR_RO(po[i]);
const SEXP *ppo = STRING_PTR_RO(po[i]);
for (ssize_t j=0; j<len_x; ++j) {
if (px[j]==pvalues[i]) {
SET_STRING_ELT(ans, j, ppo[j & amask[i]]);
Expand All @@ -574,7 +574,7 @@ SEXP vswitchR(SEXP x, SEXP values, SEXP outputs, SEXP na, SEXP nthreads, SEXP ch
const SEXP *restrict px = SEXPPTR_RO(x);
const SEXP *restrict pvalues = SEXPPTR_RO(values);
for (ssize_t i=0; i<len_values; ++i) {
SEXP *ppo = STRING_PTR_RO(po[i]);
const SEXP *ppo = STRING_PTR_RO(po[i]);
for (ssize_t j=0; j<len_x; ++j) {
if (R_compute_identical(px[j], pvalues[i], 0)) {
SET_STRING_ELT(ans, j, ppo[j & amask[i]]);
Expand Down

0 comments on commit 1a0bf42

Please sign in to comment.