File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -779,6 +779,18 @@ static SEXP R_GetGlobalCacheLoc(SEXP symbol)
779779*/
780780
781781R_BindingType R_GetBindingType (SEXP sym , SEXP env ) {
782+ // We are currently getting the location in the environment twice:
783+ // - In `R_BindingIsActive()`
784+ // - In `Rf_findVarInFrame3()`
785+ // Ideally we'd do it once, which would require manually walking
786+ // over the environment frame / hashtable and get the location to
787+ // inspect.
788+
789+ // This check must be before `Rf_findVarInFrame3()` because that
790+ // forces active bindings
791+ if (R_BindingIsActive (sym , env ))
792+ return R_BindingTypeActive ;
793+
782794 SEXP value = Rf_findVarInFrame3 (env , sym , FALSE);
783795
784796 if (value == R_UnboundValue )
@@ -794,9 +806,6 @@ R_BindingType R_GetBindingType(SEXP sym, SEXP env) {
794806 return R_BindingTypeDelayedPromise ;
795807 }
796808
797- if (R_BindingIsActive (sym , env ))
798- return R_BindingTypeActive ;
799-
800809 return R_BindingTypeValue ;
801810}
802811
You can’t perform that action at this time.
0 commit comments