summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-07-17 20:49:21 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-07-17 20:49:21 -0700
commitd959876ad6b23e504b360fbefc877b1b721ffee4 (patch)
treebe20d2ea9279b9a21158168c025308010ac297ab
parente6e93749bd0d7357f8f8031733616c3585ef758d (diff)
downloadtxr-d959876ad6b23e504b360fbefc877b1b721ffee4.tar.gz
txr-d959876ad6b23e504b360fbefc877b1b721ffee4.tar.bz2
txr-d959876ad6b23e504b360fbefc877b1b721ffee4.zip
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.
-rw-r--r--eval.c25
1 files 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;
}