[Rcpp-commits] r4295 - in pkg/Rcpp: . inst/include/Rcpp inst/include/Rcpp/api/meat inst/include/Rcpp/traits src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Mar 29 08:33:00 CET 2013


Author: romain
Date: 2013-03-29 08:33:00 +0100 (Fri, 29 Mar 2013)
New Revision: 4295

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/include/Rcpp/DottedPair.h
   pkg/Rcpp/inst/include/Rcpp/Named.h
   pkg/Rcpp/inst/include/Rcpp/api/meat/DottedPair.h
   pkg/Rcpp/inst/include/Rcpp/traits/named_object.h
   pkg/Rcpp/src/api.cpp
Log:
fix data frame creation performance issue

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2013-03-27 09:36:18 UTC (rev 4294)
+++ pkg/Rcpp/ChangeLog	2013-03-29 07:33:00 UTC (rev 4295)
@@ -1,3 +1,11 @@
+2013-03-29 Romain Francois <romain at r-enthusiasts.com>
+
+        * include/Rcpp/traits/named_object.h: only keep named_object<SEXP>
+        * include/Rcpp/Named.h: Named generates named_object<SEXP>
+        * include/Rcpp/api/meat/DottedPair.h: adapt to changes above
+        * include/Rcpp/DottedPair.h: idem
+        * src/api.cpp: define DottedPair::Proxy::operator=( named_object<SEXP> )
+
 2013-03-27 Romain Francois <romain at r-enthusiasts.com>
 
         * include/Rcpp/vector/MatrixRow.h : removed unintended printed messaged

Modified: pkg/Rcpp/inst/include/Rcpp/DottedPair.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/DottedPair.h	2013-03-27 09:36:18 UTC (rev 4294)
+++ pkg/Rcpp/inst/include/Rcpp/DottedPair.h	2013-03-29 07:33:00 UTC (rev 4295)
@@ -2,7 +2,7 @@
 //
 // DottedPair.h: Rcpp R/C++ interface class library -- dotted pair list template
 //
-// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
 //
 // This file is part of Rcpp.
 //
@@ -110,8 +110,7 @@
 		template <typename T>
 		Proxy& operator=(const T& rhs) ;
 		
-		template <typename U>
-		Proxy& operator=(const traits::named_object<U>& rhs) ;
+		Proxy& operator=(const traits::named_object<SEXP>& rhs) ;
 		
 		template <typename T> operator T() const ;
 		

Modified: pkg/Rcpp/inst/include/Rcpp/Named.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Named.h	2013-03-27 09:36:18 UTC (rev 4294)
+++ pkg/Rcpp/inst/include/Rcpp/Named.h	2013-03-29 07:33:00 UTC (rev 4295)
@@ -2,7 +2,7 @@
 //
 // Named.h: Rcpp R/C++ interface class library -- named object 
 //
-// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
 //
 // This file is part of Rcpp.
 //
@@ -30,8 +30,8 @@
 	Argument( const std::string& name_) : name(name_){} 
 	
 	template<typename T>
-	inline traits::named_object<T> operator=( const T& t){
-		return traits::named_object<T>( name, t ) ;	
+	inline traits::named_object<SEXP> operator=( const T& t){
+		return traits::named_object<SEXP>( name, wrap(t) ) ;	
 	}
 	
 	std::string name ;	
@@ -41,8 +41,8 @@
 	return Argument( name );	
 }
 template <typename T>
-inline traits::named_object<T> Named( const std::string& name, const T& o){
-	return traits::named_object<T>( name, o );	
+inline traits::named_object<SEXP> Named( const std::string& name, const T& o){
+	return traits::named_object<SEXP>( name, wrap(o) );	
 }
 
 namespace internal{

Modified: pkg/Rcpp/inst/include/Rcpp/api/meat/DottedPair.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/api/meat/DottedPair.h	2013-03-27 09:36:18 UTC (rev 4294)
+++ pkg/Rcpp/inst/include/Rcpp/api/meat/DottedPair.h	2013-03-29 07:33:00 UTC (rev 4295)
@@ -2,7 +2,7 @@
 //
 // DottedPair.h: Rcpp R/C++ interface class library --  DottedPair meat
 //
-// Copyright (C) 2012    Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2012 - 2013    Dirk Eddelbuettel and Romain Francois
 //
 // This file is part of Rcpp.
 //
@@ -32,11 +32,6 @@
     template <typename T> 
     DottedPair::Proxy::operator T() const{ return as<T>(get()); } 
 
-    template <typename U>
-    DottedPair::Proxy& DottedPair::Proxy::operator=(const traits::named_object<U>& rhs){
-    	return set( rhs.object, rhs.name.c_str() ) ;
-    }
-		
     template <typename T>
 	void DottedPair::push_front( const T& object){
 		setSEXP( grow(object, m_sexp) ) ;

Modified: pkg/Rcpp/inst/include/Rcpp/traits/named_object.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/named_object.h	2013-03-27 09:36:18 UTC (rev 4294)
+++ pkg/Rcpp/inst/include/Rcpp/traits/named_object.h	2013-03-29 07:33:00 UTC (rev 4295)
@@ -1,9 +1,9 @@
 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
 /* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
 //
-// has_iterator.h: Rcpp R/C++ interface class library -- identify if a class has a nested iterator typedef
+// named_object.h: Rcpp R/C++ interface class library -- named SEXP
 //
-// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
 //
 // This file is part of Rcpp.
 //
@@ -31,20 +31,28 @@
 template <typename T> struct needs_protection : false_type{} ;
 template <> struct needs_protection<SEXP> : true_type{} ;	
 
-template <typename T> class named_object {
-	public:
-		named_object( const std::string& name_, const T& o_) : 
-		name(name_), object(o_){}
-		const std::string& name ;
-		const T& object ;
-		
-} ;
+template <typename T> class named_object ; 
+// {
+// 	public:
+// 		named_object( const std::string& name_, const T& o_) : 
+// 			name(name_), object(o_){}
+// 		const std::string& name ;
+// 		const T& object ;
+// 		
+// } ;
 template <> class named_object<SEXP> {
 public:
 	named_object( const std::string& name_, const SEXP& o_):
-	name(name_), object(o_){
+		name(name_), object(o_)
+	{
 		R_PreserveObject(object) ;	
 	}
+	
+	named_object( const named_object<SEXP>& other ) : 
+		name(other.name), object(other.object)
+	{
+		R_PreserveObject(object) ;	
+	}
 	~named_object(){
 		R_ReleaseObject(object) ;	
 	}

Modified: pkg/Rcpp/src/api.cpp
===================================================================
--- pkg/Rcpp/src/api.cpp	2013-03-27 09:36:18 UTC (rev 4294)
+++ pkg/Rcpp/src/api.cpp	2013-03-29 07:33:00 UTC (rev 4295)
@@ -453,7 +453,11 @@
         }
         node = x ;
     }
-        
+     
+    DottedPair::Proxy& DottedPair::Proxy::operator=(const traits::named_object<SEXP>& rhs){
+    	return set( rhs.object, rhs.name.c_str() ) ;
+    }
+	
     DottedPair::Proxy& DottedPair::Proxy::operator=(const Proxy& rhs){
         return set(rhs) ;
     }



More information about the Rcpp-commits mailing list