From da8a0292657d41a31b3aa0fa248dd7edc83025ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 9 May 2017 10:34:11 +0200 Subject: [PATCH 1/2] interface change: use R_xlen_t for loop unrolling --- inst/include/Rcpp/internal/wrap.h | 4 ++-- inst/include/Rcpp/macros/unroll.h | 30 +++++++++++++++--------------- inst/include/Rcpp/vector/Vector.h | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/inst/include/Rcpp/internal/wrap.h b/inst/include/Rcpp/internal/wrap.h index fc91d880a..3d41d55bb 100644 --- a/inst/include/Rcpp/internal/wrap.h +++ b/inst/include/Rcpp/internal/wrap.h @@ -116,9 +116,9 @@ namespace Rcpp { Shield x(Rf_allocVector(RTYPE, size)); typedef typename ::Rcpp::traits::storage_type::type STORAGE; - int __trip_count = size >> 2; + R_xlen_t __trip_count = size >> 2; STORAGE* start = r_vector_start(x); - int i = 0; + R_xlen_t i = 0; for (; __trip_count > 0; --__trip_count) { start[i] = first[i]; i++; start[i] = first[i]; i++; diff --git a/inst/include/Rcpp/macros/unroll.h b/inst/include/Rcpp/macros/unroll.h index 7a89658d2..38931cb88 100644 --- a/inst/include/Rcpp/macros/unroll.h +++ b/inst/include/Rcpp/macros/unroll.h @@ -2,7 +2,7 @@ // // unroll.h: Rcpp R/C++ interface class library -- loop unrolling macro // -// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -23,8 +23,8 @@ #define Rcpp__macros_unroll_h #define RCPP_LOOP_UNROLL_PTR(TARGET,SOURCE) \ -int __trip_count = n >> 2 ; \ -int i = 0 ; \ +R_xlen_t __trip_count = n >> 2 ; \ +R_xlen_t i = 0 ; \ for ( ; __trip_count > 0 ; --__trip_count) { \ *TARGET++ = SOURCE[i++] ; \ *TARGET++ = SOURCE[i++] ; \ @@ -45,8 +45,8 @@ switch (n - i){ \ #define RCPP_LOOP_UNROLL(TARGET,SOURCE) \ -int __trip_count = n >> 2 ; \ -int i = 0 ; \ +R_xlen_t __trip_count = n >> 2 ; \ +R_xlen_t i = 0 ; \ for ( ; __trip_count > 0 ; --__trip_count) { \ TARGET[i] = SOURCE[i] ; i++ ; \ TARGET[i] = SOURCE[i] ; i++ ; \ @@ -65,22 +65,22 @@ switch (n - i){ \ {} \ } -#define RCPP_LOOP_UNROLL_LHSFUN(TARGET,FUN,SOURCE) \ -int __trip_count = n >> 2 ; \ -int i = 0 ; \ +#define RCPP_LOOP_UNROLL_LHSFUN(TARGET,FUN,SOURCE) \ +R_xlen_t __trip_count = n >> 2 ; \ +R_xlen_t i = 0 ; \ for ( ; __trip_count > 0 ; --__trip_count) { \ - TARGET[FUN(i)] = SOURCE[i] ; i++ ; \ - TARGET[FUN(i)] = SOURCE[i] ; i++ ; \ - TARGET[FUN(i)] = SOURCE[i] ; i++ ; \ - TARGET[FUN(i)] = SOURCE[i] ; i++ ; \ + TARGET[FUN(i)] = SOURCE[i] ; i++ ; \ + TARGET[FUN(i)] = SOURCE[i] ; i++ ; \ + TARGET[FUN(i)] = SOURCE[i] ; i++ ; \ + TARGET[FUN(i)] = SOURCE[i] ; i++ ; \ } \ switch (n - i){ \ case 3: \ - TARGET[FUN(i)] = SOURCE[i] ; i++ ; \ + TARGET[FUN(i)] = SOURCE[i] ; i++ ; \ case 2: \ - TARGET[FUN(i)] = SOURCE[i] ; i++ ; \ + TARGET[FUN(i)] = SOURCE[i] ; i++ ; \ case 1: \ - TARGET[FUN(i)] = SOURCE[i] ; i++ ; \ + TARGET[FUN(i)] = SOURCE[i] ; i++ ; \ case 0: \ default: \ {} \ diff --git a/inst/include/Rcpp/vector/Vector.h b/inst/include/Rcpp/vector/Vector.h index 076ed47ab..3f7609f38 100644 --- a/inst/include/Rcpp/vector/Vector.h +++ b/inst/include/Rcpp/vector/Vector.h @@ -1075,7 +1075,7 @@ class Vector : template - inline void import_expression( const T& other, int n ) { + inline void import_expression( const T& other, R_xlen_t n ) { iterator start = begin() ; RCPP_LOOP_UNROLL(start,other) } From 5bba15612a981bdb2cd35205de8bf529ab4ce0e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sat, 8 Jul 2017 23:35:58 +0200 Subject: [PATCH 2/2] up year --- inst/include/Rcpp/vector/Vector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/include/Rcpp/vector/Vector.h b/inst/include/Rcpp/vector/Vector.h index 3f7609f38..fb26110d2 100644 --- a/inst/include/Rcpp/vector/Vector.h +++ b/inst/include/Rcpp/vector/Vector.h @@ -2,7 +2,7 @@ // // Vector.h: Rcpp R/C++ interface class library -- vectors // -// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. //