Skip to content

Commit 4e50e2b

Browse files
authored
Merge pull request #688 from krlmlr/f-Wconversion-2
Reduce -Wconversion warnings for sugar code
2 parents 5f20d1a + d4ecba1 commit 4e50e2b

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ inline void incr(Rcomplex* lhs, const Rcomplex& rhs) {
6363

6464

6565
inline void div(double* lhs, R_xlen_t rhs) {
66-
*lhs /= rhs;
66+
*lhs /= static_cast<double>(rhs);
6767
}
6868

6969
inline void div(Rcomplex* lhs, R_xlen_t rhs) {
70-
lhs->r /= rhs;
71-
lhs->i /= rhs;
70+
lhs->r /= static_cast<double>(rhs);
71+
lhs->i /= static_cast<double>(rhs);
7272
}
7373

7474

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace sugar {
5757
inline void Normalize(Vector<REALSXP>& p, int require_k, bool replace)
5858
{
5959
double sum = 0.0;
60-
int npos = 0, i = 0, n = p.size();
60+
R_xlen_t npos = 0, i = 0, n = p.size();
6161

6262
for ( ; i < n; i++) {
6363
if (!R_FINITE(p[i]) || (p[i] < 0)) {

inst/include/Rcpp/sugar/functions/strings/trimws.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ inline Vector<STRSXP> trimws(const Vector<STRSXP>& x, const char* which = "both"
133133
}
134134

135135
inline Matrix<STRSXP> trimws(const Matrix<STRSXP>& x, const char* which = "both") {
136-
R_xlen_t i = 0, nr = x.nrow(), nc = x.ncol(), sz = x.size();
136+
R_xlen_t i = 0, sz = x.size();
137+
int nr = x.nrow(), nc = x.ncol();
137138
Matrix<STRSXP> res = no_init(nr, nc);
138139
std::string buffer;
139140

0 commit comments

Comments
 (0)