-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
Added as() and clone() to Nullable #423
Conversation
LGTM |
/** | ||
* Return a clone of m_sexp as a T | ||
*/ | ||
inline T clone() const { return Rcpp::clone(Rcpp::as< T >(get())); } |
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.
So technically the call is just AWFUL it:
- Shallow copies in the return from
Rcpp::as()
- Deep copies inside the `Rcpp::clone()' function
- Shallow copies in the return from
Rcpp::clone()
- Shallow copies in the return from
Nullable::clone()
- Probably shallow copies again when the end user receives it.
There should really be a better way. Best I can come up with is a SEXP Rcpp::clone(SEXP obj)
function which would remove the need for some of this.
Any other thoughts?
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.
Don't we usually call wrap()
to convert to a SEXP
which would make feeding in clone()
more straightfoward?
OK. It's a lot better now. We keep it as a
Much more satisfying. |
And same performance tweak to |
Well, nobody cared to second this but on the upside nobody howled either :) Planning to fold this in later this morning. |
No problem. It's just convenience stuff. |
Added |
No one shouted so will fold this one now. |
Added as() and clone() to Nullable
Fixes #421