Skip to content

Commit 57fe1bd

Browse files
committed
Avoid r_env_find() in env_bind()
1 parent 24e8997 commit 57fe1bd

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/internal/env-binding.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,18 +330,13 @@ void env_poke_active(r_obj* env, r_obj* sym, r_obj* fn, r_obj* eval_env) {
330330

331331
static
332332
r_obj* env_get(r_obj* env, r_obj* sym) {
333-
// Can't use `r_env_get()` because we can't error with missing arguments
334-
r_obj* out = r_env_find(env, sym);
335-
336-
if (out == r_syms.unbound) {
333+
if (!r_env_has(env, sym)) {
337334
return rlang_zap;
338335
}
339336

340-
if (r_typeof(out) == R_TYPE_promise) {
341-
KEEP(out);
342-
out = r_eval(out, r_envs.base);
343-
FREE(1);
337+
if (r_env_has_missing(env, sym)) {
338+
return r_missing_arg;
344339
}
345340

346-
return out;
341+
return r_env_get(env, sym);
347342
}

0 commit comments

Comments
 (0)