Skip to content

Commit 7ed6a66

Browse files
committed
clipply StartupCache
1 parent 33642a5 commit 7ed6a66

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

turbopack/crates/turbo-tasks-backend/src/database/startup_cache.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ impl<T: KeyValueDatabase> Borrow<[u8]> for ValueBuffer<'_, T> {
8686
}
8787
}
8888

89+
type Cache = ByKeySpace<DashMap<Vec<u8>, Option<Vec<u8>>, BuildHasherDefault<FxHasher>>>;
90+
8991
pub struct StartupCacheLayer<T: KeyValueDatabase> {
9092
database: T,
9193
path: PathBuf,
9294
fresh_db: bool,
9395
cache_size: AtomicUsize,
94-
cache: ByKeySpace<DashMap<Vec<u8>, Option<Vec<u8>>, BuildHasherDefault<FxHasher>>>,
96+
cache: Cache,
9597
restored_map: ByKeySpace<FxHashMap<&'static [u8], &'static [u8]>>,
9698
restored: Vec<u8>,
9799
}
@@ -154,7 +156,7 @@ impl<T: KeyValueDatabase> KeyValueDatabase for StartupCacheLayer<T> {
154156
T::lower_read_transaction(tx)
155157
}
156158

157-
fn begin_read_transaction<'l>(&'l self) -> Result<Self::ReadTransaction<'l>> {
159+
fn begin_read_transaction(&self) -> Result<Self::ReadTransaction<'_>> {
158160
self.database.begin_read_transaction()
159161
}
160162

@@ -282,8 +284,8 @@ impl<'a, T: KeyValueDatabase> WriteBatch<'a> for StartupCacheWriteBatch<'a, T> {
282284
pos += write_key_value_pair(
283285
&mut writer,
284286
key_space,
285-
*key,
286-
*value,
287+
key,
288+
value,
287289
&mut size_buffer,
288290
)?;
289291
if pos + 24 >= CACHE_SIZE_LIMIT {
@@ -321,8 +323,8 @@ fn write_key_value_pair(
321323
let value_len = value.len();
322324
size_buffer.copy_from_slice(&(value_len as u32).to_be_bytes());
323325
writer.write_all(&*size_buffer)?;
324-
writer.write_all(&key)?;
325-
writer.write_all(&value)?;
326+
writer.write_all(key)?;
327+
writer.write_all(value)?;
326328
Ok(9 + key_len + value_len)
327329
}
328330

0 commit comments

Comments
 (0)