File tree 2 files changed +5
-3
lines changed
2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ rayon = { version = "1.10.0", optional = true }
29
29
30
30
# Stuff we want Update impls for by default
31
31
compact_str = { version = " 0.8" , optional = true }
32
+ thin-vec = " 0.2.13"
32
33
33
34
[features ]
34
35
default = [" salsa_unstable" , " rayon" , " macros" ]
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use std::{
5
5
} ;
6
6
7
7
use parking_lot:: RwLock ;
8
+ use thin_vec:: ThinVec ;
8
9
9
10
use crate :: { zalsa:: MemoIngredientIndex , zalsa_local:: QueryOrigin } ;
10
11
@@ -13,7 +14,7 @@ use crate::{zalsa::MemoIngredientIndex, zalsa_local::QueryOrigin};
13
14
/// and memo tables are attached to those salsa structs as auxiliary data.
14
15
#[ derive( Default ) ]
15
16
pub ( crate ) struct MemoTable {
16
- memos : RwLock < Vec < MemoEntry > > ,
17
+ memos : RwLock < ThinVec < MemoEntry > > ,
17
18
}
18
19
19
20
pub ( crate ) trait Memo : Any + Send + Sync {
@@ -131,8 +132,8 @@ impl MemoTable {
131
132
) -> Option < NonNull < M > > {
132
133
let mut memos = self . memos . write ( ) ;
133
134
let memo_ingredient_index = memo_ingredient_index. as_usize ( ) ;
134
- if memos. len ( ) < memo_ingredient_index + 1 {
135
- memos. resize_with ( memo_ingredient_index + 1 , MemoEntry :: default ) ;
135
+ while memos. len ( ) < memo_ingredient_index + 1 {
136
+ memos. push ( MemoEntry { data : None } ) ;
136
137
}
137
138
let old_entry = memos[ memo_ingredient_index] . data . replace ( MemoEntryData {
138
139
type_id : TypeId :: of :: < M > ( ) ,
You can’t perform that action at this time.
0 commit comments