[Rcpp-commits] r2887 - in pkg/Rcpp: . inst/include/Rcpp/vector

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jan 25 22:51:13 CET 2011


Author: edd
Date: 2011-01-25 22:51:13 +0100 (Tue, 25 Jan 2011)
New Revision: 2887

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
   pkg/Rcpp/inst/include/Rcpp/vector/eval_methods.h
Log:
More Rf_install() to local SEXP


Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2011-01-25 21:18:42 UTC (rev 2886)
+++ pkg/Rcpp/ChangeLog	2011-01-25 21:51:13 UTC (rev 2887)
@@ -6,6 +6,8 @@
 	* inst/include/Rcpp/DottedPair.h: idem
 	* inst/include/Rcpp/grow.h: idem
 	* inst/include/Rcpp/Module.h: idem
+	* inst/include/Rcpp/vector/eval_methods.h: idem
+	* inst/include/Rcpp/vector/Vector.h: idem
 
 2011-01-25  Douglas Bates  <bates at stat.wisc.edu>
 

Modified: pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2011-01-25 21:18:42 UTC (rev 2886)
+++ pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2011-01-25 21:51:13 UTC (rev 2887)
@@ -367,10 +367,8 @@
 				Rf_setAttrib( y, R_NamesSymbol, x ) ;
 			} else {
 				/* use the slower and more flexible version (callback to R) */
-			
-				SEXP new_vec = PROTECT( internal::try_catch( 
-				    Rf_lang3( Rf_install("names<-"), parent, x )
-				)) ;
+			        SEXP namesSym = Rf_install( "names<-" );
+				SEXP new_vec = PROTECT( internal::try_catch(Rf_lang3( namesSym, parent, x ))) ;
 				/* names<- makes a new vector, so we have to change 
 				   the SEXP of the parent of this proxy */
 				const_cast<Vector&>(parent).set_sexp( new_vec ) ;

Modified: pkg/Rcpp/inst/include/Rcpp/vector/eval_methods.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/eval_methods.h	2011-01-25 21:18:42 UTC (rev 2886)
+++ pkg/Rcpp/inst/include/Rcpp/vector/eval_methods.h	2011-01-25 21:51:13 UTC (rev 2887)
@@ -1,4 +1,4 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
 //
 // eval_methods.h: Rcpp R/C++ interface class library -- 
 //
@@ -24,21 +24,23 @@
 
 namespace internal{
 	
-	template <int RTYPE> class expr_eval_methods {
-	public:
-		typedef Rcpp::Vector<RTYPE> VECTOR ;
+    template <int RTYPE> class expr_eval_methods {
+    public:
+	typedef Rcpp::Vector<RTYPE> VECTOR ;
 		
-		SEXP eval(){
-			SEXP xp = ( static_cast<VECTOR&>(*this) ).asSexp() ;
-			return try_catch( Rf_lang2( Rf_install( "eval" ), xp ) ) ;
-		} ;
-		SEXP eval( const ::Rcpp::Environment& env ){
-			SEXP xp = ( static_cast<VECTOR&>(*this) ).asSexp() ;
-			return try_catch( Rf_lang3( Rf_install( "eval" ), xp, env.asSexp() ) ) ;
-		} ;
+	SEXP eval(){
+	    SEXP xp = ( static_cast<VECTOR&>(*this) ).asSexp() ;
+	    SEXP evalSym = Rf_install( "eval" );
+	    return try_catch( Rf_lang2( evalSym, xp ) ) ;
 	} ;
+	SEXP eval( const ::Rcpp::Environment& env ){
+	    SEXP xp = ( static_cast<VECTOR&>(*this) ).asSexp() ;
+	    SEXP evalSym = Rf_install( "eval" );
+	    return try_catch( Rf_lang3( evalSym, xp, env.asSexp() ) ) ;
+	} ;
+    } ;
 	
-	template<> class eval_methods<EXPRSXP> : public expr_eval_methods<EXPRSXP> {} ;
+    template<> class eval_methods<EXPRSXP> : public expr_eval_methods<EXPRSXP> {} ;
 	
 }
 #endif



More information about the Rcpp-commits mailing list