Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ rayon = { version = "1.10.0", optional = true }

# Stuff we want Update impls for by default
compact_str = { version = "0.8", optional = true }
thin-vec = "0.2.13"

[features]
default = ["salsa_unstable", "rayon", "macros"]
Expand Down
7 changes: 4 additions & 3 deletions src/table/memo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{
};

use parking_lot::RwLock;
use thin_vec::ThinVec;

use crate::{zalsa::MemoIngredientIndex, zalsa_local::QueryOrigin};

Expand All @@ -13,7 +14,7 @@ use crate::{zalsa::MemoIngredientIndex, zalsa_local::QueryOrigin};
/// and memo tables are attached to those salsa structs as auxiliary data.
#[derive(Default)]
pub(crate) struct MemoTable {
memos: RwLock<Vec<MemoEntry>>,
memos: RwLock<ThinVec<MemoEntry>>,
}

pub(crate) trait Memo: Any + Send + Sync {
Expand Down Expand Up @@ -131,8 +132,8 @@ impl MemoTable {
) -> Option<NonNull<M>> {
let mut memos = self.memos.write();
let memo_ingredient_index = memo_ingredient_index.as_usize();
if memos.len() < memo_ingredient_index + 1 {
memos.resize_with(memo_ingredient_index + 1, MemoEntry::default);
while memos.len() < memo_ingredient_index + 1 {
memos.push(MemoEntry { data: None });
}
let old_entry = memos[memo_ingredient_index].data.replace(MemoEntryData {
type_id: TypeId::of::<M>(),
Expand Down