-
Notifications
You must be signed in to change notification settings - Fork 49
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
Remove non-API calls to R: SETLENGTH, SET_TRUELENGTH Fix #355 #358
Conversation
For reference gcc 4.8 CI failing is unrelated: #356 |
@nx10 If you do it this way, you also have to modify this as well cpp11/inst/include/cpp11/r_vector.hpp Lines 910 to 926 in 51f4cd5
Or else it will trigger |
I see this issue in the CRAN checks for rjsoncons too. Reverting to diff --git a/inst/include/cpp11/r_vector.hpp b/inst/include/cpp11/r_vector.hpp
index 4831c2f..eee63f7 100644
--- a/inst/include/cpp11/r_vector.hpp
+++ b/inst/include/cpp11/r_vector.hpp
@@ -895,14 +895,8 @@ inline void r_vector<T>::clear() {
length_ = 0;
}
-inline SEXP truncate(SEXP x, R_xlen_t length, R_xlen_t capacity) {
-#if R_VERSION >= R_Version(3, 4, 0)
- SETLENGTH(x, length);
- SET_TRUELENGTH(x, capacity);
- SET_GROWABLE_BIT(x);
-#else
- x = safe[Rf_lengthgets](x, length);
-#endif
+inline SEXP truncate(SEXP x, R_xlen_t length) {
+ x = safe[Rf_xlengthgets](x, length);
return x;
}
@@ -914,11 +908,11 @@ inline r_vector<T>::operator SEXP() const {
return data_;
}
if (length_ < capacity_) {
- p->data_ = truncate(p->data_, length_, capacity_);
+ p->data_ = truncate(p->data_, length_);
SEXP nms = names();
auto nms_size = Rf_xlength(nms);
if ((nms_size > 0) && (length_ < nms_size)) {
- nms = truncate(nms, length_, capacity_);
+ nms = truncate(nms, length_);
names() = nms;
}
}
@chainsawriot seems to suggest
|
There will likely need to be benchmarking done to see how badly this effects performance. It was done this way to avoid an extra copy of the data when truncating. But additionally unwind protection used in As this function gets called when coercing cpp11 vectors to SEXP it is a pretty hot area of the code. |
We will be looking at this soon to get a patch release of cpp11 out. It seems that the R-devel non-API tweaks have slowed down to the point that we should be able to send a release in without much fear of something else additionally getting marked non-API later on. We are going to lose access to In the meantime, if you have a package that uses cpp11 you can send in a release of that package even with the NOTE. CRAN is aware of it and will approve your package. |
Seems like R/CRAN does not want these used publicly anymore starting with 4.5.*
See details in #355