[Rcpp-commits] r3303 - pkg/int64/inst/include/int64
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Nov 7 12:47:44 CET 2011
Author: romain
Date: 2011-11-07 12:47:44 +0100 (Mon, 07 Nov 2011)
New Revision: 3303
Modified:
pkg/int64/inst/include/int64/as_long.h
Log:
simpler as_long impl based on new LongVector ctor
Modified: pkg/int64/inst/include/int64/as_long.h
===================================================================
--- pkg/int64/inst/include/int64/as_long.h 2011-11-07 11:45:28 UTC (rev 3302)
+++ pkg/int64/inst/include/int64/as_long.h 2011-11-07 11:47:44 UTC (rev 3303)
@@ -24,42 +24,9 @@
namespace int64{
namespace internal{
-
template <typename LONG>
SEXP as_long(SEXP x){
- int n = Rf_length(x) ;
- int64::LongVector<LONG> data(n) ;
- switch( TYPEOF(x) ){
- case INTSXP:
- {
- int* p_x = INTEGER(x) ;
- for( int i=0;i<n; i++){
- data.set( i, (LONG)p_x[i] ) ;
- }
- break ;
- }
- case STRSXP:
- {
- for( int i=0;i<n; i++){
- LONG tmp = read_string<LONG>(CHAR(STRING_ELT(x,i))) ;
- data.set( i, tmp ) ;
- }
- break;
- }
- case REALSXP:
- {
- double* pd_x = REAL(x) ;
- for( int i=0;i<n; i++){
- LONG tmp = pd_x[i] ;
- data.set( i, tmp ) ;
- }
- break;
- }
- default:
- Rf_error( "incompatible type" ) ;
- }
- return data ;
-
+ return LongVector<LONG>(x) ;
}
} // namespace internal
More information about the Rcpp-commits
mailing list