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 658f135 commit 445833c
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 114 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: kit
Type: Package
Title: Data Manipulation Functions Implemented in C
Version: 0.0.18
Date: 2024-06-06
Version: 0.0.19
Date: 2024-06-26
Authors@R: c(person("Morgan", "Jacob", role = c("aut", "cre", "cph"), email = "[email protected]"),
person("Sebastian", "Krantz", role = "ctb"))
Author: Morgan Jacob [aut, cre, cph], Sebastian Krantz [ctb]
Expand Down
24 changes: 12 additions & 12 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
6071edd604dbeb75308cfbedc7790398 *cleanup
d2761d00effd7b096a5bea21bc38742e *configure
b3e2183a8c074fd4a4257c00e36b615a *DESCRIPTION
1663021b062fc51d7db2efe337e3c735 *inst/NEWS.Rd
333734960a1399c3fb463327554da3e2 *DESCRIPTION
66302e8b5f49ea7f34b2608a1f397f52 *inst/NEWS.Rd
a87b0f223435ed35607e8514562b8bfe *LICENSE
2ddfa8d8739668eedda260e6ddc935d4 *man/charToFact.Rd
8f19a2c9feb2f352580fd4892650f285 *man/count.Rd
Expand All @@ -16,22 +16,22 @@ a137f7855b41b074e2babaf8a1562551 *man/shareData.Rd
54f91d543a10f8c9aef7082da2b86de7 *man/topn.Rd
a7f31cee15b9624dab8f4d13d3c66bad *man/vswitch.Rd
c797ca387dccc02751cfe85108fb0159 *NAMESPACE
afdd17df63f1a06c519bea52c696c04e *R/call.R
4eb6d6a80ed6d9396f89c21ff11ff3e0 *R/call.R
2d6c06dfc570d456af125c160cf150d7 *README.md
f8a685dd117b590adaae0c0c6dfb8de2 *src/dup.c
e89fa490ca241429f9f7adbea3b931de *src/dupLen.c
7772ede8a29575aee4fc449383fa5008 *src/dup.c
2b2b6f22af562d8c40127c69cc541331 *src/dupLen.c
5eaee76c99ff42679577592ae9c5a29f *src/fpos.c
835f517eb81445beeb99fd24c046c6de *src/iif.c
015be143fce94516ad10b968df592df5 *src/iif.c
6d91dc90d2db4ede5f044b824d4f34a3 *src/init.c
b929f70ab892f155eeead08c160ffc25 *src/kit.h
a52426250b954a335b1121948e057ee7 *src/Makevars.in
95e3011e37d9dde0d75f3a3819b2acd3 *src/Makevars.win
b13fc207b052914c3d078eb5759cecce *src/nswitch.c
0f3d02f6281d978ffb89098311aa0305 *src/psort.c
1d70a2f6d6d5821039dd4ba0caab8a68 *src/psum.c
2c6e521b15f59e489cf31a53c1530b60 *src/share.c
1e8b11cf04b116653c0a82a20f72490b *src/nswitch.c
7b6cc295ee89e397e47957097cf15417 *src/psort.c
d9e5ee62440914d68cec114cd9717af2 *src/psum.c
7589054d8388fe7ed3354a5aa388eb02 *src/share.c
ef9329d7e748c13b9526fca1788a1891 *src/topn.c
2cde70cd4cbf783f0b01a9dd70c01ac9 *src/utils.c
719ad7753149642df0dd7c0c38c57e28 *src/vswitch.c
8b27a6955a60f8c94b6ae39845948bb9 *src/utils.c
ffd709a7cfedf05d54c7577f8a248a28 *src/vswitch.c
6af1b66c0c90f6809c960e2133c1b5e4 *tests/test_kit.R
0dce9bd953fe40b1c8fae3d01a597e7c *tests/test_kit.Rout.save
2 changes: 1 addition & 1 deletion R/call.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ vswitch = function(x, values, outputs, default=NULL, nThread=getOption("kit.
omp = if(.Call(CompEnabledR)) "enabled" else "disabled" #nocov
nth = getOption("kit.nThread") #nocov
thd = if (nth > 1L) " threads)" else " thread)" #nocov
packageStartupMessage(paste0("Attaching kit 0.0.18 (OPENMP ",omp," using ",nth,thd)) #nocov
packageStartupMessage(paste0("Attaching kit 0.0.19 (OPENMP ",omp," using ",nth,thd)) #nocov
} #nocov

.onLoad = function(libname, pkgname) { #nocov
Expand Down
8 changes: 8 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

\newcommand{\CRANpkg}{\href{https://CRAN.R-project.org/package=#1}{\pkg{#1}}}

\section{version 0.0.19 (2024-06-26)}{
\subsection{Bug Fixes}{
\itemize{
\item Fix warnings in C code.
}
}
}

\section{version 0.0.18 (2024-06-06)}{
\subsection{Bug Fixes}{
\itemize{
Expand Down
6 changes: 3 additions & 3 deletions src/dup.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ SEXP dupMatrixR(SEXP x, SEXP uniq, Rboolean idx, SEXP fromLast) {
}
} break;
case STRSXP : {
const SEXP *restrict px = STRING_PTR(x);
const SEXP *restrict px = STRING_PTR_RO(x);
if (buniq) {
if (pfromLast) {
for (R_xlen_t i = len_i-1; i > -1; --i) {
Expand Down Expand Up @@ -1259,7 +1259,7 @@ SEXP dupVecR(SEXP x, SEXP uniq, SEXP fromLast) {
}
} break;
case STRSXP: {
const SEXP *restrict px = STRING_PTR(x);
const SEXP *restrict px = STRING_PTR_RO(x);
size_t id = 0;
if (buniq) {
if (pfromLast) {
Expand Down Expand Up @@ -1458,7 +1458,7 @@ SEXP dupVecIndexOnlyR(SEXP x) {
}
} break;
case STRSXP: {
const SEXP *restrict px = STRING_PTR(x);
const SEXP *restrict px = STRING_PTR_RO(x);
size_t id = 0;
for (int i = 0; i < n; ++i) {
id = HASH(((intptr_t) px[i] & 0xffffffff), K);
Expand Down
4 changes: 2 additions & 2 deletions src/dupLen.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ SEXP dupLenMatrixR(SEXP x) {
}
} break;
case STRSXP : {
const SEXP *restrict px = STRING_PTR(x);
const SEXP *restrict px = STRING_PTR_RO(x);
for (R_xlen_t i = 0; i < len_i; ++i) {
R_xlen_t key = 0;
for (R_xlen_t j = 0; j < len_x; ++j) {
Expand Down Expand Up @@ -388,7 +388,7 @@ SEXP dupLenVecR(SEXP x) {
}
} break;
case STRSXP: {
const SEXP *restrict px = STRING_PTR(x);
const SEXP *restrict px = STRING_PTR_RO(x);
size_t id = 0;
for (int i = 0; i < n; ++i) {
id = HASH(((intptr_t) px[i] & 0xffffffff), K);
Expand Down
14 changes: 7 additions & 7 deletions src/iif.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ SEXP iifR(SEXP l, SEXP a, SEXP b, SEXP na, SEXP tprom, SEXP nthreads) {
const ssize_t amask = len_a>1 ? SSIZE_MAX : 0;
const ssize_t bmask = len_b>1 ? SSIZE_MAX : 0;
const ssize_t namask = len_na>1 ? SSIZE_MAX : 0;
const SEXP *restrict pa = STRING_PTR(a);
const SEXP *restrict pb = STRING_PTR(b);
const SEXP *restrict pna = na_non_null ? STRING_PTR(na) : NULL;
const SEXP *restrict pa = STRING_PTR_RO(a);
const SEXP *restrict pb = STRING_PTR_RO(b);
const SEXP *restrict pna = na_non_null ? STRING_PTR_RO(na) : NULL;
for (ssize_t i=0; i<len_l; ++i) {
SET_STRING_ELT(ans, i, pl[i] == 1 ? pa[i & amask] : (pl[i] == 0 ? pb[i & bmask] :(na_non_null ? pna[i & namask] : NA_STRING)));
}
Expand Down Expand Up @@ -459,7 +459,7 @@ SEXP nifR(SEXP na, SEXP rho, SEXP args) {
}
} break;
case STRSXP: {
const SEXP *restrict pouts = STRING_PTR(outs);
const SEXP *restrict pouts = STRING_PTR_RO(outs);
if (imask) {
for (ssize_t j=0; j<len2; ++j) {
if (pcons[j]==1) {
Expand All @@ -479,7 +479,7 @@ SEXP nifR(SEXP na, SEXP rho, SEXP args) {
}
if (i==dn) {
const ssize_t bmask = len_na>1 ? SSIZE_MAX : 0;
const SEXP *restrict pna = nonna ? STRING_PTR(na) : NULL;
const SEXP *restrict pna = nonna ? STRING_PTR_RO(na) : NULL;
for (ssize_t j=0; j<l; ++j) {
SET_STRING_ELT(ans, p[j], nonna ? pna[p[j] & bmask] : NA_STRING);
}
Expand Down Expand Up @@ -733,7 +733,7 @@ SEXP nifInternalR(SEXP na, SEXP args) { // # nocov start
}
} break;
case STRSXP: {
const SEXP *restrict pouts = STRING_PTR(outs);
const SEXP *restrict pouts = STRING_PTR_RO(outs);
if (imask) {
for (ssize_t j=0; j<len2; ++j) {
if (pcons[j]==1) {
Expand All @@ -753,7 +753,7 @@ SEXP nifInternalR(SEXP na, SEXP args) { // # nocov start
}
if (i==dn) {
const ssize_t bmask = len_na>1 ? SSIZE_MAX : 0;
const SEXP *restrict pna = nonna ? STRING_PTR(na) : NULL;
const SEXP *restrict pna = nonna ? STRING_PTR_RO(na) : NULL;
for (ssize_t j=0; j<l; ++j) {
SET_STRING_ELT(ans, p[j], nonna ? pna[p[j] & bmask] : NA_STRING);
}
Expand Down
44 changes: 22 additions & 22 deletions src/nswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) {
bool utfcon = false;
if (pchkenc && type_x == STRSXP) {
if (!isMixEnc(x)) {
const cetype_t cx = getCharCE(STRING_PTR(x)[0]);
const cetype_t cx = getCharCE(STRING_PTR_RO(x)[0]);
for (ssize_t i = 0; i < n; ++i) {
if(cx != getCharCE(STRING_PTR(PTR_ETL(args,2*i))[0])) {
if(cx != getCharCE(STRING_PTR_RO(PTR_ETL(args,2*i))[0])) {
utfcon = true;
break;
}
Expand All @@ -124,7 +124,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) {
vans = PROTECT(allocVector(STRSXP, n));
nprotect = 2;
for (ssize_t i = 0; i < n; ++i) {
SET_STRING_ELT(vans, i, STRING_PTR(enc2UTF8(PTR_ETL(args,2*i)))[0]);
SET_STRING_ELT(vans, i, STRING_PTR_RO(enc2UTF8(PTR_ETL(args,2*i)))[0]);
}
}
}
Expand Down Expand Up @@ -196,11 +196,11 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) {
}
} break;
case STRSXP: {
const SEXP *restrict px = STRING_PTR(utfcon ? xans : x);
const SEXP *restrict px = STRING_PTR_RO(utfcon ? xans : x);
OMP_PARALLEL_FOR(nth)
for (ssize_t i = 0; i < n; ++i) {
const int *restrict pto = LOGICAL(PTR_ETL(args, 2*i+1));
const SEXP *restrict pvalues = STRING_PTR(utfcon ? vans : PTR_ETL(args, 2*i));
const SEXP *restrict pvalues = STRING_PTR_RO(utfcon ? vans : PTR_ETL(args, 2*i));
for (ssize_t j = 0; j < len_x; ++j) {
if (px[j] == pvalues[0]) {
pans[j] = pto[j & amask[i]];
Expand Down Expand Up @@ -289,11 +289,11 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) {
}
} break;
case STRSXP: {
const SEXP *restrict px = STRING_PTR(utfcon ? xans : x);
const SEXP *restrict px = STRING_PTR_RO(utfcon ? xans : x);
OMP_PARALLEL_FOR(nth)
for (ssize_t i = 0; i < n; ++i) {
const int *restrict pto = INTEGER(PTR_ETL(args, 2*i+1));
const SEXP *restrict pvalues = STRING_PTR(utfcon ? vans : PTR_ETL(args, 2*i));
const SEXP *restrict pvalues = STRING_PTR_RO(utfcon ? vans : PTR_ETL(args, 2*i));
for (ssize_t j = 0; j < len_x; ++j) {
if (px[j] == pvalues[0]) {
pans[j] = pto[j & amask[i]];
Expand Down Expand Up @@ -382,11 +382,11 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) {
}
} break;
case STRSXP: {
const SEXP *restrict px = STRING_PTR(utfcon ? xans : x);
const SEXP *restrict px = STRING_PTR_RO(utfcon ? xans : x);
OMP_PARALLEL_FOR(nth)
for (ssize_t i = 0; i < n; ++i) {
const double *restrict pto = REAL(PTR_ETL(args, 2*i+1));
const SEXP *restrict pvalues = STRING_PTR(utfcon ? vans : PTR_ETL(args, 2*i));
const SEXP *restrict pvalues = STRING_PTR_RO(utfcon ? vans : PTR_ETL(args, 2*i));
for (ssize_t j = 0; j < len_x; ++j) {
if (px[j] == pvalues[0]) {
pans[j] = pto[j & amask[i]];
Expand Down Expand Up @@ -476,11 +476,11 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) {
}
} break;
case STRSXP: {
const SEXP *restrict px = STRING_PTR(utfcon ? xans : x);
const SEXP *restrict px = STRING_PTR_RO(utfcon ? xans : x);
OMP_PARALLEL_FOR(nth)
for (ssize_t i = 0; i < n; ++i) {
const Rcomplex *restrict pto = COMPLEX(PTR_ETL(args, 2*i+1));
const SEXP *restrict pvalues = STRING_PTR(utfcon ? vans : PTR_ETL(args, 2*i));
const SEXP *restrict pvalues = STRING_PTR_RO(utfcon ? vans : PTR_ETL(args, 2*i));
for (ssize_t j = 0; j < len_x; ++j) {
if (px[j] == pvalues[0]) {
pans[j] = pto[j & amask[i]];
Expand Down Expand Up @@ -508,7 +508,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) {
* This part is for STRING
*/
case STRSXP:{
const SEXP *restrict pna = nonna ? STRING_PTR(na) : NULL;
const SEXP *restrict pna = nonna ? STRING_PTR_RO(na) : NULL;
ssize_t namask = len_na>1 ? SSIZE_MAX : 0;
for (ssize_t j=0; j<len_x; ++j) {
SET_STRING_ELT(ans, j, nonna ? pna[j & namask] : NA_STRING);
Expand All @@ -517,7 +517,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) {
case LGLSXP: {
const int *restrict px = LOGICAL(x);
for (ssize_t i = 0; i < n; ++i) {
const SEXP *restrict pto = STRING_PTR(PTR_ETL(args, 2*i+1));
const SEXP *restrict pto = STRING_PTR_RO(PTR_ETL(args, 2*i+1));
const int *restrict pvalues = LOGICAL(PTR_ETL(args, 2*i));
for (ssize_t j = 0; j < len_x; ++j) {
if (px[j] == pvalues[0]) {
Expand All @@ -529,7 +529,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) {
case INTSXP: {
const int *restrict px = INTEGER(x);
for (ssize_t i = 0; i < n; ++i) {
const SEXP *restrict pto = STRING_PTR(PTR_ETL(args, 2*i+1));
const SEXP *restrict pto = STRING_PTR_RO(PTR_ETL(args, 2*i+1));
const int *restrict pvalues = INTEGER(PTR_ETL(args, 2*i));
for (ssize_t j = 0; j < len_x; ++j) {
if (px[j] == pvalues[0]) {
Expand All @@ -541,7 +541,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) {
case REALSXP: {
const double *restrict px = REAL(x);
for (ssize_t i = 0; i < n; ++i) {
const SEXP *restrict pto = STRING_PTR(PTR_ETL(args, 2*i+1));
const SEXP *restrict pto = STRING_PTR_RO(PTR_ETL(args, 2*i+1));
const double *restrict pvalues = REAL(PTR_ETL(args, 2*i));
for (ssize_t j = 0; j < len_x; ++j) {
if (px[j] == pvalues[0]) {
Expand All @@ -553,7 +553,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) {
case CPLXSXP: {
const Rcomplex *restrict px = COMPLEX(x);
for (ssize_t i = 0; i < n; ++i) {
const SEXP *restrict pto = STRING_PTR(PTR_ETL(args, 2*i+1));
const SEXP *restrict pto = STRING_PTR_RO(PTR_ETL(args, 2*i+1));
const Rcomplex *restrict pvalues = COMPLEX(PTR_ETL(args, 2*i));
for (ssize_t j = 0; j < len_x; ++j) {
if (EQUAL_CPLX(px[j],pvalues[0])) {
Expand All @@ -563,10 +563,10 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) {
}
} break;
case STRSXP: {
const SEXP *restrict px = STRING_PTR(utfcon ? xans : x);
const SEXP *restrict px = STRING_PTR_RO(utfcon ? xans : x);
for (ssize_t i = 0; i < n; ++i) {
const SEXP *restrict pto = STRING_PTR(PTR_ETL(args, 2*i+1));
const SEXP *restrict pvalues = STRING_PTR(utfcon ? vans : PTR_ETL(args, 2*i));
const SEXP *restrict pto = STRING_PTR_RO(PTR_ETL(args, 2*i+1));
const SEXP *restrict pvalues = STRING_PTR_RO(utfcon ? vans : PTR_ETL(args, 2*i));
for (ssize_t j = 0; j < len_x; ++j) {
if (px[j] == pvalues[0]) {
SET_STRING_ELT(ans, j, pto[j & amask[i]]);
Expand All @@ -577,7 +577,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) {
case VECSXP: {
const SEXP *restrict px = SEXPPTR_RO(x);
for (ssize_t i = 0; i < n; ++i) {
const SEXP *restrict pto = STRING_PTR(PTR_ETL(args, 2*i+1));
const SEXP *restrict pto = STRING_PTR_RO(PTR_ETL(args, 2*i+1));
const SEXP *restrict pvalues = SEXPPTR_RO(PTR_ETL(args, 2*i));
for (ssize_t j = 0; j < len_x; ++j) {
if (R_compute_identical(px[j],pvalues[0],0)) {
Expand Down Expand Up @@ -651,10 +651,10 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) {
}
} break;
case STRSXP: {
const SEXP *restrict px = STRING_PTR(utfcon ? xans : x);
const SEXP *restrict px = STRING_PTR_RO(utfcon ? xans : x);
for (ssize_t i = 0; i < n; ++i) {
const SEXP *restrict pto = SEXPPTR_RO(PTR_ETL(args, 2*i+1));
const SEXP *restrict pvalues = STRING_PTR(utfcon ? vans : PTR_ETL(args, 2*i));
const SEXP *restrict pvalues = STRING_PTR_RO(utfcon ? vans : PTR_ETL(args, 2*i));
for (ssize_t j = 0; j < len_x; ++j) {
if (px[j] == pvalues[0]) {
SET_VECTOR_ELT(ans, j, pto[j & amask[i]]);
Expand Down
Loading

0 comments on commit 445833c

Please sign in to comment.