From d5a38c3491d47b2c62fe388d6e3e431c50117e5c Mon Sep 17 00:00:00 2001 From: Johnathan Sharratt Date: Thu, 1 Jun 2023 00:24:09 +1000 Subject: [PATCH] Fixed an heavy memory allocaiton hotspot --- lib/virtual-fs/src/static_fs.rs | 4 ++-- lib/virtual-fs/src/webc_fs.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/virtual-fs/src/static_fs.rs b/lib/virtual-fs/src/static_fs.rs index 48131c70eb6..e43c2318bc5 100644 --- a/lib/virtual-fs/src/static_fs.rs +++ b/lib/virtual-fs/src/static_fs.rs @@ -55,7 +55,7 @@ impl FileOpener for StaticFileSystem { let file = (*self.volumes) .get(&volume) .ok_or(FsError::EntryNotFound)? - .get_file_entry(&format!("{}", path.display())) + .get_file_entry(path.to_string_lossy().as_ref()) .map_err(|_e| FsError::EntryNotFound)?; Ok(Box::new(WebCFile { @@ -69,7 +69,7 @@ impl FileOpener for StaticFileSystem { } None => { for (volume, v) in self.volumes.iter() { - let entry = match v.get_file_entry(&format!("{}", path.display())) { + let entry = match v.get_file_entry(path.to_string_lossy().as_ref()) { Ok(s) => s, Err(_) => continue, // error }; diff --git a/lib/virtual-fs/src/webc_fs.rs b/lib/virtual-fs/src/webc_fs.rs index cab9f07b631..03a99e4c19e 100644 --- a/lib/virtual-fs/src/webc_fs.rs +++ b/lib/virtual-fs/src/webc_fs.rs @@ -90,7 +90,7 @@ where .volumes .get(&volume) .ok_or(FsError::EntryNotFound)? - .get_file_entry(&format!("{}", path.display())) + .get_file_entry(path.to_string_lossy().as_ref()) .map_err(|_e| FsError::EntryNotFound)?; Ok(Box::new(WebCFile { @@ -108,7 +108,7 @@ where None => continue, // error }; - let entry = match v.get_file_entry(&format!("{}", path.display())) { + let entry = match v.get_file_entry(path.to_string_lossy().as_ref()) { Ok(s) => s, Err(_) => continue, // error };