From 59d74689dc8f98965a688c4b4f18349f5d04a071 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Fri, 8 Jul 2022 12:36:36 +0200 Subject: [PATCH] Copy filetable more efficiently. --- src/context/memory.rs | 4 ++-- src/scheme/proc.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/context/memory.rs b/src/context/memory.rs index fd6315c..255723e 100644 --- a/src/context/memory.rs +++ b/src/context/memory.rs @@ -251,8 +251,8 @@ impl UserGrants { let exactly_after_size = holes.remove(&grant.end_address()); // There was a range that began exactly prior to the to-be-freed region, so simply - // increment the size such that it occupies the grant too. If in additional there was a - // grant directly after the grant, include it too in the size. + // increment the size such that it occupies the grant too. If in addition there was a grant + // directly after the grant, include it too in the size. if let Some((hole_offset, hole_size)) = holes.range_mut(..grant.start_address()).next_back().filter(|(offset, size)| offset.data() + **size == grant.start_address().data()) { *hole_size = grant.end_address().data() - hole_offset.data() + exactly_after_size.unwrap_or(0); } else { diff --git a/src/scheme/proc.rs b/src/scheme/proc.rs index 05da3cf..28225a6 100644 --- a/src/scheme/proc.rs +++ b/src/scheme/proc.rs @@ -435,7 +435,7 @@ impl Scheme for ProcScheme { if buf != b"copy" { return Err(Error::new(EINVAL)); } - let new_filetable = Arc::try_new(RwLock::new(filetable.read().iter().cloned().collect::>())).map_err(|_| Error::new(ENOMEM))?; + let new_filetable = Arc::try_new(RwLock::new(filetable.read().clone())).map_err(|_| Error::new(ENOMEM))?; Handle { info: Info {