Skip to content

Commit

Permalink
avoid double-allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
tguichaoua committed Feb 24, 2024
1 parent e044b0a commit c13f828
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions crates/bevy_asset/src/io/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ impl Dir {
dir = self.get_or_insert_dir(parent);
}
dir.0.write().assets.insert(
path.file_name()
.unwrap()
.to_string_lossy()
.into_owned()
.into_boxed_str(),
path.file_name().unwrap().to_string_lossy().into(),
Data {
value: value.into(),
path: path.to_owned(),
Expand All @@ -64,11 +60,7 @@ impl Dir {
dir = self.get_or_insert_dir(parent);
}
dir.0.write().metadata.insert(
path.file_name()
.unwrap()
.to_string_lossy()
.into_owned()
.into_boxed_str(),
path.file_name().unwrap().to_string_lossy().into(),
Data {
value: value.into(),
path: path.to_owned(),
Expand All @@ -81,7 +73,7 @@ impl Dir {
let mut full_path = PathBuf::new();
for c in path.components() {
full_path.push(c);
let name = c.as_os_str().to_string_lossy().to_string().into_boxed_str();
let name = c.as_os_str().to_string_lossy().into();
dir = {
let dirs = &mut dir.0.write().dirs;
dirs.entry(name)
Expand Down

0 comments on commit c13f828

Please sign in to comment.