@@ -9,18 +9,18 @@ SEXP transpose(SEXP l, SEXP fill, SEXP ignoreArg, SEXP keepNamesArg, SEXP listCo
99 error (_ ("l must be a list." ));
1010 if (!length (l ))
1111 return (copyAsPlain (l ));
12- if (!isLogical (ignoreArg ) || LOGICAL (ignoreArg )[0 ] == NA_LOGICAL )
12+ if (!isLogical (ignoreArg ) || LOGICAL_RO (ignoreArg )[0 ] == NA_LOGICAL )
1313 error (_ ("ignore.empty should be logical TRUE/FALSE." ));
14- bool ignore = LOGICAL (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 (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 ));
@@ -61,22 +61,22 @@ SEXP transpose(SEXP l, SEXP fill, SEXP ignoreArg, SEXP keepNamesArg, SEXP listCo
6161 } else PROTECT (li ); // extra PROTECT just to help rchk by avoiding two counter variables
6262 switch (maxtype ) {
6363 case LGLSXP : {
64- const int * ili = LOGICAL (li );
65- const int ifill = LOGICAL (fill )[0 ];
64+ const int * ili = LOGICAL_RO (li );
65+ const int ifill = LOGICAL_RO (fill )[0 ];
6666 for (int j = 0 ; j < maxlen ; j ++ ) {
6767 LOGICAL (ansp [j + rn ])[k ] = j < len ? ili [j ] : ifill ;
6868 }
6969 } break ;
7070 case INTSXP : {
71- const int * ili = INTEGER (li );
72- const int ifill = INTEGER (fill )[0 ];
71+ const int * ili = INTEGER_RO (li );
72+ const int ifill = INTEGER_RO (fill )[0 ];
7373 for (int j = 0 ; j < maxlen ; j ++ ) {
7474 INTEGER (ansp [j + rn ])[k ] = j < len ? ili [j ] : ifill ;
7575 }
7676 } break ;
7777 case REALSXP : {
78- const double * dli = REAL (li );
79- const double dfill = REAL (fill )[0 ];
78+ const double * dli = REAL_RO (li );
79+ const double dfill = REAL_RO (fill )[0 ];
8080 for (int j = 0 ; j < maxlen ; j ++ ) {
8181 REAL (ansp [j + rn ])[k ] = j < len ? dli [j ] : dfill ;
8282 }
0 commit comments