File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -150,12 +150,16 @@ SEXP uniqlengths(SEXP x, SEXP n) {
150150 // seems very similar to rbindlist.c:uniq_lengths. TODO: centralize into common function
151151 if (TYPEOF (x ) != INTSXP ) error (_ ("Input argument 'x' to 'uniqlengths' must be an integer vector" ));
152152 if (TYPEOF (n ) != INTSXP || length (n ) != 1 ) error (_ ("Input argument 'n' to 'uniqlengths' must be an integer vector of length 1" ));
153- R_len_t len = length (x );
153+ const R_len_t len = length (x );
154154 SEXP ans = PROTECT (allocVector (INTSXP , len ));
155+
156+ const int * px = INTEGER_RO (x );
157+ int * pans = INTEGER (ans );
158+
155159 for (R_len_t i = 1 ; i < len ; i ++ ) {
156- INTEGER ( ans ) [i - 1 ] = INTEGER ( x ) [i ] - INTEGER ( x ) [i - 1 ];
160+ pans [i - 1 ] = px [i ] - px [i - 1 ];
157161 }
158- if (len > 0 ) INTEGER ( ans ) [len - 1 ] = INTEGER (n )[0 ] - INTEGER ( x ) [len - 1 ] + 1 ;
162+ if (len > 0 ) pans [len - 1 ] = INTEGER (n )[0 ] - px [len - 1 ] + 1 ;
159163 UNPROTECT (1 );
160164 return (ans );
161165}
You can’t perform that action at this time.
0 commit comments