Skip to content

Commit

Permalink
Fixed an heavy memory allocaiton hotspot
Browse files Browse the repository at this point in the history
  • Loading branch information
john-sharratt committed May 31, 2023
1 parent 0c6dc37 commit 470e6e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/virtual-fs/src/static_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
};
Expand Down
4 changes: 2 additions & 2 deletions lib/virtual-fs/src/webc_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
};
Expand Down

0 comments on commit 470e6e1

Please sign in to comment.