Skip to content

Commit 83856f7

Browse files
committed
implemented improvements as requested
1 parent f8e9e85 commit 83856f7

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/inrange.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ SEXP inrange(SEXP ansArg, SEXP xoArg, SEXP startsArg, SEXP lenArg)
55
{
66
int *ans = INTEGER(ansArg);
77
const int *xo = INTEGER_RO(xoArg);
8-
const int *starts = INTEGER(startsArg), *len = INTEGER_RO(lenArg);
8+
const int *starts = INTEGER_RO(startsArg), *len = INTEGER_RO(lenArg);
99
const int n = length(startsArg), nxo = length(xoArg);
1010
for (int i = 0; i < n; i++) {
1111
for (int j = starts[i] - 1; j < starts[i] - 1 + len[i]; j++) {

src/subset.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ void subsetVectorRaw(SEXP ans, SEXP source, SEXP idx, const bool anyNA)
4949

5050
switch(TYPEOF(source)) {
5151
case INTSXP: case LGLSXP: {
52-
int *sp = INTEGER(source);
52+
const int *sp = INTEGER_RO(source);
5353
int *ap = INTEGER(ans);
5454
PARLOOP(NA_INTEGER)
5555
} break;
5656
case REALSXP : {
5757
if (INHERITS(source, char_integer64)) {
58-
int64_t *sp = (int64_t *)REAL(source);
58+
const int64_t *sp = (int64_t *)REAL_RO(source);
5959
int64_t *ap = (int64_t *)REAL(ans);
6060
PARLOOP(INT64_MIN)
6161
} else {
62-
double *sp = REAL(source);
62+
const double *sp = REAL_RO(source);
6363
double *ap = REAL(ans);
6464
PARLOOP(NA_REAL)
6565
}

src/transpose.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ SEXP transpose(SEXP l, SEXP fill, SEXP ignoreArg, SEXP keepNamesArg, SEXP listCo
1111
return(copyAsPlain(l));
1212
if (!isLogical(ignoreArg) || LOGICAL(ignoreArg)[0] == NA_LOGICAL)
1313
error(_("ignore.empty should be logical TRUE/FALSE."));
14-
bool ignore = LOGICAL_RO(ignoreArg)[0];
14+
const bool ignore = LOGICAL_RO(ignoreArg)[0];
1515
if (!(isNull(keepNamesArg) || (isString(keepNamesArg) && LENGTH(keepNamesArg) == 1)))
1616
error(_("keep.names should be either NULL, or the name of the first column of the result in which to place the names of the input"));
17-
bool rn = !isNull(keepNamesArg);
17+
const bool rn = !isNull(keepNamesArg);
1818
if (length(fill) != 1)
1919
error(_("fill must be a length 1 vector, such as the default NA"));
20-
R_len_t ln = LENGTH(l);
20+
const R_len_t ln = LENGTH(l);
2121
if (!IS_TRUE_OR_FALSE(listColsArg))
2222
error(_("list.cols should be logical TRUE/FALSE."));
23-
bool listCol = LOGICAL_RO(listColsArg)[0];
23+
const bool listCol = LOGICAL_RO(listColsArg)[0];
2424

2525
// preprocessing
2626
int maxlen = 0, zerolen = 0;
@@ -39,7 +39,7 @@ SEXP transpose(SEXP l, SEXP fill, SEXP ignoreArg, SEXP keepNamesArg, SEXP listCo
3939
if (listCol) maxtype = VECSXP; // need to keep preprocessing for zerolen
4040
fill = PROTECT(coerceVector(fill, maxtype)); nprotect++;
4141
SEXP ans = PROTECT(allocVector(VECSXP, maxlen + rn)); nprotect++;
42-
int anslen = (ignore) ? (ln - zerolen) : ln;
42+
const int anslen = (ignore) ? (ln - zerolen) : ln;
4343
if (rn) {
4444
SEXP tt;
4545
SET_VECTOR_ELT(ans, 0, tt = allocVector(STRSXP, anslen));

0 commit comments

Comments
 (0)