> I see a huge difference in this set of
> examples ( which are painfully repetitive on many levels)
> that are identical except for [] vs. (). This is true whether
> or not ret appears on the RHS. Am I missing something here?
That matches what the source says, e.g. Rcpp/include/Rcpp/vector/Vector.h:
inline Proxy operator[]( int i ){ return cache.ref(i) ; }
inline Proxy operator()( const size_t& i) throw(index_out_of_bounds){
return cache.ref( offset(i) ) ;
The offset() call checks that i is within range. So, for your artificial
example that is most of the effort.
(Just seen Dirk's reply; I think what may be going on is that
cache.ref(i) may get optimized to end up as a single pointer
dereference, but the function call to offset() is too complex, so it
ends up not even getting inlined.)
Darren
--
Darren Cook, Software Researcher/Developer
http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel