-
-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce -Wconversion warnings for sugar code #688
Conversation
@@ -133,7 +133,8 @@ inline Vector<STRSXP> trimws(const Vector<STRSXP>& x, const char* which = "both" | |||
} | |||
|
|||
inline Matrix<STRSXP> trimws(const Matrix<STRSXP>& x, const char* which = "both") { | |||
R_xlen_t i = 0, nr = x.nrow(), nc = x.ncol(), sz = x.size(); | |||
R_xlen_t i = 0, sz = x.size(); | |||
int nr = x.nrow(), nc = x.ncol(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just double-checking here: Even with R_xlen_t
, rows and cols are still int
in R itself, but number of matrix elements can exceed int
. Do I have that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's the way it's implemented currently, see R-ints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per https://stat.ethz.ch/R-manual/R-devel/library/base/html/LongVectors.html
Arrays (including matrices) can be based on long vectors provided each of their dimensions is at most 2^31 - 1:
Type | Storage size | Value range |
---|---|---|
int | 2 or 4 bytes | -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647 |
In theory, you are bounded by: (2^31 - 1)^2 = 4,611,686,014,132,420,609
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me too, was just trying to confirm. Because otherwise nrow, ncol should not be int here and in Matrix.
Have a test running with the now-merged PR. Things take some time of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not uint though. R only uses signed ints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R> .Machine$integer.max
[1] 2147483647
R>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quoted the 2byte bounds instead of 4byte blah.
Codecov Report
@@ Coverage Diff @@
## master #688 +/- ##
=======================================
Coverage 89.77% 89.77%
=======================================
Files 66 66
Lines 3511 3511
=======================================
Hits 3152 3152
Misses 359 359 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Let's get a second nod from someone and I'll put it in.
Tests are good so far (just committed for #687) so in it goes with a fresh test. |
2/n.