From d959876ad6b23e504b360fbefc877b1b721ffee4 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 17 Jul 2023 20:49:21 -0700 Subject: Do not unnecessarily invalidate vm binding cache. * eval.c (op_defsymacro, rt_defsymacro, makunbound, fmakunbound): Don't call vm_invalidate_binding if there is no binding for the symbol. --- eval.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/eval.c b/eval.c index f82747b2..d95672f7 100644 --- a/eval.c +++ b/eval.c @@ -2154,6 +2154,7 @@ static val op_defsymacro(val form, val env) { val args = rest(form); val sym = first(args); + val varexisted = gethash_d(top_vb, sym); (void) env; @@ -2162,17 +2163,20 @@ static val op_defsymacro(val form, val env) if (!opt_compat || opt_compat > 143) remhash(special, sym); sethash(top_smb, sym, second(args)); - vm_invalidate_binding(sym); + if (varexisted) + vm_invalidate_binding(sym); return sym; } static val rt_defsymacro(val sym, val def) { + val varexisted = gethash_d(top_vb, sym); autoload_try_var(sym); remhash(top_vb, sym); remhash(special, sym); sethash(top_smb, sym, def); - vm_invalidate_binding(sym); + if (varexisted) + vm_invalidate_binding(sym); return sym; } @@ -6027,22 +6031,29 @@ static val makunbound(val sym) } } - remhash(top_vb, sym); + if (gethash_d(top_vb, sym)) { + remhash(top_vb, sym); + vm_invalidate_binding(sym); + } + remhash(top_smb, sym); remhash(special, sym); - vm_invalidate_binding(sym); - return sym; } static val fmakunbound(val sym) { autoload_try_var(sym); - remhash(top_fb, sym); + + if (gethash_d(top_fb, sym)) { + remhash(top_fb, sym); + vm_invalidate_binding(sym); + } + if (opt_compat && opt_compat <= 127) remhash(top_mb, sym); - vm_invalidate_binding(sym); + return sym; } -- cgit v1.2.3