Always start off with an empty cache

Adding a cache layer can only be done with a snapshot and rollback.
This is necessary to prevent extra variables just lying around on the
toplevel of the layout cache.
This commit is contained in:
Ayaz Hafiz 2023-01-30 13:08:21 -06:00
parent 1e22a2bbcd
commit a16ea95a04
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 6 additions and 4 deletions

View file

@ -5731,6 +5731,8 @@ fn build_pending_specializations<'a>(
derived_module: &derived_module,
};
let layout_cache_snapshot = layout_cache.snapshot();
// Add modules' decls to Procs
for index in 0..declarations.len() {
use roc_can::expr::DeclarationTag::*;
@ -6108,6 +6110,8 @@ fn build_pending_specializations<'a>(
}
}
layout_cache.rollback_to(layout_cache_snapshot);
procs_base.module_thunks = module_thunks.into_bump_slice();
let find_specializations_end = Instant::now();

View file

@ -120,10 +120,8 @@ pub struct LayoutCache<'a> {
impl<'a> LayoutCache<'a> {
pub fn new(interner: TLLayoutInterner<'a>, target_info: TargetInfo) -> Self {
let mut cache = std::vec::Vec::with_capacity(4);
cache.push(CacheLayer::default());
let mut raw_cache = std::vec::Vec::with_capacity(4);
raw_cache.push(CacheLayer::default());
let cache = std::vec::Vec::with_capacity(4);
let raw_cache = std::vec::Vec::with_capacity(4);
Self {
target_info,
cache,