revisionstore: remove into_boxed_slice usage

Summary:
I learned that Box::from() can be used to copy a slice into a box, so
let's replace my previous to_vec().into_boxed_slice() with this.

Reviewed By: quark-zju

Differential Revision: D9350961

fbshipit-source-id: 94053b82cd64923dfabc9acf3a9dab6daca20cf3
This commit is contained in:
Durham Goode 2018-08-16 12:30:37 -07:00 committed by Facebook Github Bot
parent 37c830f836
commit 94c6ad00ef
2 changed files with 2 additions and 2 deletions

View File

@ -402,7 +402,7 @@ impl<'a> Iterator for DataPackIterator<'a> {
Some(match entry {
Ok(ref e) => {
self.offset = e.next_offset;
Ok(Key::new(e.filename.to_vec().into_boxed_slice(), e.node))
Ok(Key::new(Box::from(e.filename), e.node))
}
Err(e) => Err(e),
})

View File

@ -45,7 +45,7 @@ impl MutableHistoryPack {
// To get the inner map, then insert our new NodeInfo. Unfortunately it requires
// key.name().clone() though. So we have to do it the long way to avoid the allocation.
let entries = self.mem_index
.entry(key.name().to_vec().into_boxed_slice())
.entry(Box::from(key.name()))
.or_insert_with(|| HashMap::new());
entries.insert(key.clone(), info.clone());
Ok(())