Skip to content

Commit

Permalink
Merge pull request #792 from krlmlr/f-fallthrough
Browse files Browse the repository at this point in the history
fallthrough comments
  • Loading branch information
eddelbuettel committed Dec 21, 2017
2 parents a9d8632 + 749175b commit 4a47dcb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 38 deletions.
3 changes: 3 additions & 0 deletions inst/include/Rcpp/internal/wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,13 @@ namespace Rcpp {
switch (size - i) {
case 3:
start[i] = first[i]; i++;
// fallthrough
case 2:
start[i] = first[i]; i++;
// fallthrough
case 1:
start[i] = first[i]; i++;
// fallthrough
case 0:
default:
{}
Expand Down
76 changes: 38 additions & 38 deletions inst/include/Rcpp/macros/unroll.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,46 +44,46 @@ switch (n - i){ \
}


#define RCPP_LOOP_UNROLL(TARGET,SOURCE) \
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++ ; \
TARGET[i] = SOURCE[i] ; i++ ; \
TARGET[i] = SOURCE[i] ; i++ ; \
} \
switch (n - i){ \
case 3: \
TARGET[i] = SOURCE[i] ; i++ ; \
case 2: \
TARGET[i] = SOURCE[i] ; i++ ; \
case 1: \
TARGET[i] = SOURCE[i] ; i++ ; \
case 0: \
default: \
{} \
#define RCPP_LOOP_UNROLL(TARGET,SOURCE) \
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++ ; \
TARGET[i] = SOURCE[i] ; i++ ; \
TARGET[i] = SOURCE[i] ; i++ ; \
} \
switch (n - i){ \
case 3: \
TARGET[i] = SOURCE[i] ; i++ ; /* fallthrough */ \
case 2: \
TARGET[i] = SOURCE[i] ; i++ ; /* fallthrough */ \
case 1: \
TARGET[i] = SOURCE[i] ; i++ ; /* fallthrough */ \
case 0: \
default: \
{} \
}

#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++ ; \
} \
switch (n - i){ \
case 3: \
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
case 2: \
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
case 1: \
TARGET[FUN(i)] = SOURCE[i] ; i++ ; \
case 0: \
default: \
{} \
#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++ ; \
} \
switch (n - i){ \
case 3: \
TARGET[FUN(i)] = SOURCE[i] ; i++ ; /* fallthrough */ \
case 2: \
TARGET[FUN(i)] = SOURCE[i] ; i++ ; /* fallthrough */ \
case 1: \
TARGET[FUN(i)] = SOURCE[i] ; i++ ; /* fallthrough */ \
case 0: \
default: \
{} \
}

#endif

0 comments on commit 4a47dcb

Please sign in to comment.