Skip to content

Commit e3c8545

Browse files
krlmlreddelbuettel
authored andcommitted
Interface change: use R_xlen_t for loop unrolling (#731)
* interface change: use R_xlen_t for loop unrolling * up year
1 parent 294536a commit e3c8545

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

inst/include/Rcpp/internal/wrap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ namespace Rcpp {
116116
Shield<SEXP> x(Rf_allocVector(RTYPE, size));
117117

118118
typedef typename ::Rcpp::traits::storage_type<RTYPE>::type STORAGE;
119-
int __trip_count = size >> 2;
119+
R_xlen_t __trip_count = size >> 2;
120120
STORAGE* start = r_vector_start<RTYPE>(x);
121-
int i = 0;
121+
R_xlen_t i = 0;
122122
for (; __trip_count > 0; --__trip_count) {
123123
start[i] = first[i]; i++;
124124
start[i] = first[i]; i++;

inst/include/Rcpp/macros/unroll.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// unroll.h: Rcpp R/C++ interface class library -- loop unrolling macro
44
//
5-
// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois
66
//
77
// This file is part of Rcpp.
88
//
@@ -23,8 +23,8 @@
2323
#define Rcpp__macros_unroll_h
2424

2525
#define RCPP_LOOP_UNROLL_PTR(TARGET,SOURCE) \
26-
int __trip_count = n >> 2 ; \
27-
int i = 0 ; \
26+
R_xlen_t __trip_count = n >> 2 ; \
27+
R_xlen_t i = 0 ; \
2828
for ( ; __trip_count > 0 ; --__trip_count) { \
2929
*TARGET++ = SOURCE[i++] ; \
3030
*TARGET++ = SOURCE[i++] ; \
@@ -45,8 +45,8 @@ switch (n - i){ \
4545

4646

4747
#define RCPP_LOOP_UNROLL(TARGET,SOURCE) \
48-
int __trip_count = n >> 2 ; \
49-
int i = 0 ; \
48+
R_xlen_t __trip_count = n >> 2 ; \
49+
R_xlen_t i = 0 ; \
5050
for ( ; __trip_count > 0 ; --__trip_count) { \
5151
TARGET[i] = SOURCE[i] ; i++ ; \
5252
TARGET[i] = SOURCE[i] ; i++ ; \
@@ -65,22 +65,22 @@ switch (n - i){ \
6565
{} \
6666
}
6767

68-
#define RCPP_LOOP_UNROLL_LHSFUN(TARGET,FUN,SOURCE) \
69-
int __trip_count = n >> 2 ; \
70-
int i = 0 ; \
68+
#define RCPP_LOOP_UNROLL_LHSFUN(TARGET,FUN,SOURCE) \
69+
R_xlen_t __trip_count = n >> 2 ; \
70+
R_xlen_t i = 0 ; \
7171
for ( ; __trip_count > 0 ; --__trip_count) { \
72-
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
73-
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
74-
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
75-
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
72+
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
73+
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
74+
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
75+
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
7676
} \
7777
switch (n - i){ \
7878
case 3: \
79-
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
79+
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
8080
case 2: \
81-
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
81+
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
8282
case 1: \
83-
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
83+
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
8484
case 0: \
8585
default: \
8686
{} \

inst/include/Rcpp/vector/Vector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// Vector.h: Rcpp R/C++ interface class library -- vectors
44
//
5-
// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois
66
//
77
// This file is part of Rcpp.
88
//
@@ -1075,7 +1075,7 @@ class Vector :
10751075

10761076

10771077
template <typename T>
1078-
inline void import_expression( const T& other, int n ) {
1078+
inline void import_expression( const T& other, R_xlen_t n ) {
10791079
iterator start = begin() ;
10801080
RCPP_LOOP_UNROLL(start,other)
10811081
}

0 commit comments

Comments
 (0)