[Rcpp-devel] use of auxiliary functions

Davor Cubranic cubranic at stat.ubc.ca
Wed Aug 11 19:21:51 CEST 2010


On August 11, 2010 02:48:23 am romain at r-enthusiasts.com wrote:
> Le 10 août 2010 à 22:10, baptiste auguie 
<baptiste.auguie at googlemail.com> a écrit :
> > OK, thanks. I have not been able to produce a minimal code that
> > would exhibit an improved performance using this
> > passing-by-reference idea.
> 
> Hi,
> 
> It would usually make a difference when copying the object that is
> passed by value is "expensive" to copy. Rcpp objects are very cheap
> to copy and both copies refer to the same actual data (the same
> SEXP).
> 
> For internal code my recommendation would be to always use pass by
> reference and do an explicit call to clone when a real copy
> (different SEXP) is needed.

In other words, if you were passing large arma::mat's, then const 
references should make a real difference.

Davor


More information about the Rcpp-devel mailing list