Skip to content

Commit 3f35dbb

Browse files
committed
only need to check for PROMSXP in the old path
1 parent 505eb9c commit 3f35dbb

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

inst/include/Rcpp/Environment.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,11 @@ namespace Rcpp{
112112
#if R_VERSION < R_Version(4,5,0)
113113
SEXP res = Rf_findVarInFrame( env, name ) ;
114114
if (res == R_UnboundValue) return R_NilValue;
115+
if (TYPEOF(res) == PROMSXP)
116+
res = internal::Rcpp_eval_impl(res, env);
115117
#else
116118
SEXP res = R_getVarEx(name, env, FALSE, R_NilValue);
117119
#endif
118-
/* We need to evaluate if it is a promise */
119-
if( TYPEOF(res) == PROMSXP){
120-
res = internal::Rcpp_eval_impl( res, env ) ;
121-
}
122120
return res ;
123121
}
124122

@@ -146,14 +144,12 @@ namespace Rcpp{
146144
#if R_VERSION < R_Version(4,5,0)
147145
SEXP res = Rf_findVar( name, env ) ;
148146
if (res == R_UnboundValue) throw binding_not_found(name.c_str());
147+
if (TYPEOF(res) == PROMSXP)
148+
res = internal::Rcpp_eval_impl(res, env);
149149
#else
150150
SEXP res = R_getVarEx(name, env, TRUE, R_NilValue);
151151
if (res == R_NilValue) throw binding_not_found(name.c_str());
152152
#endif
153-
/* We need to evaluate if it is a promise */
154-
if( TYPEOF(res) == PROMSXP){
155-
res = internal::Rcpp_eval_impl( res, env ) ;
156-
}
157153
return res ;
158154
}
159155

0 commit comments

Comments
 (0)