Skip to content

Commit 87dc09c

Browse files
committed
couple of fixes suggested by Claude
1 parent b06d8dc commit 87dc09c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

ChangeLog

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
* inst/include/Rcpp/sugar/functions/cumprod.h: Use the previous operations
88
* inst/include/Rcpp/sugar/functions/cumsum.h: Idem
9-
* inst/include/Rcpp/sugar/functions/diff.h: Idem
9+
* inst/include/Rcpp/sugar/functions/diff.h: Idem, also fixed a bug where
10+
the diff was recomputed instead of returning the calculated value
1011
* inst/include/Rcpp/sugar/functions/rowSums.h: Idem
1112
* inst/include/Rcpp/sugar/functions/sum.h: Idem
12-
* inst/include/Rcpp/sugar/operators/minus.h: Idem
13+
* inst/include/Rcpp/sugar/operators/minus.h: Idem, also fixed a bug for
14+
an incorrect Extractor specialization in Minus_Primitive_Vector
1315
* inst/include/Rcpp/sugar/operators/plus.h: Idem
1416
* inst/include/Rcpp/sugar/operators/times.h: Idem
1517

inst/include/Rcpp/sugar/functions/diff.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ class Diff<RTYPE,false,LHS_T> : public Rcpp::VectorBase< RTYPE, false , Diff<RTY
106106
inline STORAGE operator[]( R_xlen_t i ) const {
107107
STORAGE y = lhs[i+1] ;
108108
if( previous_index != i ) previous = lhs[i] ;
109-
STORAGE diff = RCPP_SAFE_SUB(y, previous);
109+
STORAGE res = RCPP_SAFE_SUB(y, previous);
110110
previous = y ;
111111
previous_index = i+1 ;
112-
return RCPP_SAFE_SUB(y, previous);
112+
return res;
113113
}
114114
inline R_xlen_t size() const { return lhs.size() - 1 ; }
115115

0 commit comments

Comments
 (0)