[Rcpp-commits] r2878 - in pkg/Rcpp: . src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jan 22 20:21:00 CET 2011


Author: edd
Date: 2011-01-22 20:21:00 +0100 (Sat, 22 Jan 2011)
New Revision: 2878

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/src/cache.cpp
Log:
assign Rf_install to local SEXP in a one place


Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2011-01-22 18:09:26 UTC (rev 2877)
+++ pkg/Rcpp/ChangeLog	2011-01-22 19:21:00 UTC (rev 2878)
@@ -1,6 +1,7 @@
 2011-01-22  Dirk Eddelbuettel  <edd at debian.org>
 
-	* src/Function.cpp: Assign Rf_install() result to local SEXP
+	* src/cache.cpp: Assign Rf_install() result to local SEXP
+	* src/Function.cpp: idem
 	* src/RObject.cpp: idem
 	* src/Symbol.cpp: idem
 

Modified: pkg/Rcpp/src/cache.cpp
===================================================================
--- pkg/Rcpp/src/cache.cpp	2011-01-22 18:09:26 UTC (rev 2877)
+++ pkg/Rcpp/src/cache.cpp	2011-01-22 19:21:00 UTC (rev 2878)
@@ -28,33 +28,31 @@
     if( ! Rcpp_cache_ready ) init_Rcpp_cache() ;
 }
 
-namespace Rcpp{
-    namespace internal{   
-    SEXP get_Rcpp_namespace(){ 
-        maybe_init() ; return VECTOR_ELT( Rcpp_cache , 0 ) ;
-    }
-    SEXP get_rcpptrycatch(){
-       // maybe_init() ; return VECTOR_ELT( Rcpp_cache, 4 ) ; 
-       return Rf_install("rcpp_tryCatch") ;
-    }                              
-    SEXP get_evalq(){
-        // maybe_init() ; return VECTOR_ELT( Rcpp_cache, 5 ) ;
-        return Rf_install("evalq");
-    }
+namespace Rcpp {
+    namespace internal {   
+		SEXP get_Rcpp_namespace(){ 
+			maybe_init() ; return VECTOR_ELT( Rcpp_cache , 0 ) ;
+		}
+		SEXP get_rcpptrycatch(){
+			// maybe_init() ; return VECTOR_ELT( Rcpp_cache, 4 ) ; 
+			return Rf_install("rcpp_tryCatch") ; // maybe not worth assigning to SEXP
+		}                              
+		SEXP get_evalq(){
+			// maybe_init() ; return VECTOR_ELT( Rcpp_cache, 5 ) ;
+			return Rf_install("evalq");	// maybe not worth assigning to SEXP
+		}
+	}
 }
-}
 
 // only used for debugging
 SEXP get_rcpp_cache() { return Rcpp_cache ; }
 
 SEXP init_Rcpp_cache(){   
     Rcpp_cache = PROTECT( Rf_allocVector( VECSXP, 10 ) );
-	
+
     // the Rcpp namespace
-    SEXP RCPP = PROTECT( Rf_eval( 
-        Rf_lang2( Rf_install("getNamespace"), Rf_mkString("Rcpp") ), 
-        R_GlobalEnv
-    ) ) ;
+	SEXP getNamespaceSym = Rf_install("getNamespace"); // cannot be gc()'ed  once in symbol table
+    SEXP RCPP = PROTECT( Rf_eval(Rf_lang2( getNamespaceSym, Rf_mkString("Rcpp") ), R_GlobalEnv) ) ;
     SET_VECTOR_ELT( Rcpp_cache, 0, RCPP ) ;
 	reset_current_error() ;
 	// SET_VECTOR_ELT( Rcpp_cache, 4, Rf_install("rcpp_tryCatch") ) ;



More information about the Rcpp-commits mailing list