unneeded path operations

This commit is contained in:
Quaternions 2024-02-17 22:05:03 -08:00
parent c03cd0e905
commit 2273f881b2
2 changed files with 3 additions and 8 deletions

View File

@ -73,8 +73,7 @@ impl Loader{
for (asset_id,render_config_id) in self.render_config_id_from_asset_id{
let render_config=self.render_configs.get_mut(render_config_id.get() as usize).unwrap();
if let (Some(asset_id),Some(texture_id))=(asset_id,render_config.texture){
let path=std::path::PathBuf::from(format!("textures/{}.dds",asset_id.0));
if let Ok(mut file)=std::fs::File::open(path){
if let Ok(mut file)=std::fs::File::open(format!("textures/{}.dds",asset_id.0)){
//TODO: parallel
let mut data=Vec::<u8>::new();
file.read_to_end(&mut data)?;

View File

@ -40,10 +40,7 @@ impl MeshLoader{
for (mesh_path,mesh_id) in &self.mesh_paths{
let mesh_path_lower=mesh_path.to_lowercase();
//.mdl, .vvd, .dx90.vtx
let mut path=std::path::PathBuf::from(mesh_path_lower.as_str());
let file_name=std::path::PathBuf::from(path.file_stem().unwrap());
path.pop();
path.push(file_name);
let path=std::path::PathBuf::from(mesh_path_lower.as_str());
let mut vvd_path=path.clone();
let mut vtx_path=path.clone();
vvd_path.set_extension("vvd");
@ -89,8 +86,7 @@ impl Loader{
for (texture_path,render_config_id) in self.render_config_loader.texture_paths{
let render_config=self.render_config_loader.render_configs.get_mut(render_config_id.get() as usize).unwrap();
if let (Some(texture_path),Some(texture_id))=(texture_path,render_config.texture){
let path=std::path::PathBuf::from(format!("textures/{}.dds",texture_path));
if let Ok(mut file)=std::fs::File::open(path){
if let Ok(mut file)=std::fs::File::open(format!("textures/{}.dds",texture_path)){
//TODO: parallel
let mut data=Vec::<u8>::new();
file.read_to_end(&mut data)?;