[thin/cache_restore (rust)] Build the metadata space map in-place

That avoids cloning the source space map
This commit is contained in:
Ming-Hung Tsai
2021-06-11 18:16:51 +08:00
parent 9ab8dfa283
commit 4b7b3658ff
6 changed files with 97 additions and 18 deletions

View File

@@ -251,8 +251,7 @@ fn build_data_sm(w: &mut WriteBatcher, sm: &dyn SpaceMap) -> Result<Vec<u8>> {
fn build_metadata_sm(w: &mut WriteBatcher) -> Result<Vec<u8>> {
let mut sm_root = vec![0u8; SPACE_MAP_ROOT_SIZE];
let mut cur = Cursor::new(&mut sm_root);
let sm_without_meta = clone_space_map(w.sm.lock().unwrap().deref())?;
let r = write_metadata_sm(w, sm_without_meta.deref())?;
let r = write_metadata_sm(w)?;
r.pack(&mut cur)?;
Ok(sm_root)