From 2ab5db536474554c6ce5b6e22c6432476fb92ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C5=A0t=C4=9Bp=C3=A1nek?= <161520055+stepam38@users.noreply.github.com> Date: Wed, 3 Jul 2024 10:38:06 +0000 Subject: [PATCH] Check for element in cache before invalidating --- rir/src/bc/Compiler.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rir/src/bc/Compiler.cpp b/rir/src/bc/Compiler.cpp index 250120af8..51b414baf 100644 --- a/rir/src/bc/Compiler.cpp +++ b/rir/src/bc/Compiler.cpp @@ -2047,8 +2047,10 @@ SEXP Compiler::finalize() { if (TYPEOF(e) == LANGSXP) for (auto n : RList(CDR(e))) { if (CAR(e) == symbol::rm) { - ctx.code.top()->loadsSlotInCache[n] = - CompilerContext::CodeContext::BindingCacheDisabled; + auto& cache = ctx.code.top()->loadsSlotInCache; + if (cache.count(n)) + cache[n] = + CompilerContext::CodeContext::BindingCacheDisabled; } else if (TYPEOF(n) == SYMSXP) { ctx.code.top()->cacheSlotFor(n); } else {