From a592d0eb843d50366b6d753b2898449260738d0a Mon Sep 17 00:00:00 2001 From: Logan McNaughton <848146+loganmc10@users.noreply.github.com> Date: Fri, 17 Apr 2026 09:59:32 +0200 Subject: [PATCH] remove uses of to_owned (#764) * remove uses of to_owned * more * more --- build.rs | 5 ++--- src/netplay.rs | 2 +- src/ui/storage.rs | 29 +++++++++++++---------------- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/build.rs b/build.rs index 2cbcdf5..fe85e5b 100644 --- a/build.rs +++ b/build.rs @@ -62,11 +62,10 @@ fn main() { .include("parallel-rdp/parallel-rdp-standalone/vulkan-headers/include") .include("parallel-rdp/parallel-rdp-standalone/util") .include( - std::path::PathBuf::from(std::env::var("DEP_SDL3_OUT_DIR").to_owned().unwrap()) - .join("include"), + std::path::PathBuf::from(std::env::var("DEP_SDL3_OUT_DIR").unwrap()).join("include"), ) .include( - std::path::PathBuf::from(std::env::var("DEP_SDL3_TTF_OUT_DIR").to_owned().unwrap()) + std::path::PathBuf::from(std::env::var("DEP_SDL3_TTF_OUT_DIR").unwrap()) .join("include"), ); diff --git a/src/netplay.rs b/src/netplay.rs index b0a64c5..0f9ce7b 100644 --- a/src/netplay.rs +++ b/src/netplay.rs @@ -85,7 +85,7 @@ pub fn send_save(netplay: &mut Netplay, save_type: &str, save_data: &[u8], size: request.extend_from_slice(&(size as u32).to_be_bytes()); if size > 0 { - request.extend(save_data.to_owned()); + request.extend_from_slice(save_data); } netplay.tcp_stream.write_all(&request).unwrap(); } diff --git a/src/ui/storage.rs b/src/ui/storage.rs index dff4a09..470b077 100644 --- a/src/ui/storage.rs +++ b/src/ui/storage.rs @@ -135,13 +135,13 @@ pub fn get_game_crc(rom: &[u8]) -> String { } pub fn get_game_name(rom: &[u8]) -> String { - let mut game_name = "".to_owned(); let header_value = std::str::from_utf8(&rom[0x20..0x34]); if let Ok(header_value) = header_value { let re = regex::Regex::new(r"[^a-zA-Z0-9_ -]").unwrap(); - game_name = re.replace_all(header_value, "").trim().replace('\0', ""); + re.replace_all(header_value, "").trim().replace('\0', "") + } else { + String::new() } - game_name } pub fn init(ui: &mut ui::Ui, rom: &[u8]) { @@ -163,49 +163,46 @@ pub fn init(ui: &mut ui::Ui, rom: &[u8]) { ui.storage .paths .eep_file_path - .push(prefix.to_owned() + "-" + &ui.game_hash + ".eep"); + .push(format!("{}-{}.eep", prefix, ui.game_hash)); ui.storage.paths.sra_file_path.clone_from(&saves_path); ui.storage .paths .sra_file_path - .push(prefix.to_owned() + "-" + &ui.game_hash + ".sra"); + .push(format!("{}-{}.sra", prefix, ui.game_hash)); ui.storage.paths.fla_file_path.clone_from(&saves_path); ui.storage .paths .fla_file_path - .push(prefix.to_owned() + "-" + &ui.game_hash + ".fla"); + .push(format!("{}-{}.fla", prefix, ui.game_hash)); ui.storage.paths.pak_file_path.clone_from(&saves_path); ui.storage .paths .pak_file_path - .push(prefix.to_owned() + "-" + &ui.game_hash + ".mpk"); + .push(format!("{}-{}.mpk", prefix, ui.game_hash)); ui.storage.paths.sdcard_file_path.clone_from(&saves_path); ui.storage .paths .sdcard_file_path - .push(prefix.to_owned() + "-" + &ui.game_hash + ".img"); + .push(format!("{}-{}.img", prefix, ui.game_hash)); ui.storage.paths.romsave_file_path.clone_from(&saves_path); ui.storage .paths .romsave_file_path - .push(prefix.to_owned() + "-" + &ui.game_hash + ".romsave"); + .push(format!("{}-{}.romsave", prefix, ui.game_hash)); ui.storage .paths .savestate_file_path .clone_from(&states_path); - ui.storage.paths.savestate_file_path.push( - prefix.to_owned() - + "-" - + &ui.game_hash - + ".state" - + ui.storage.save_state_slot.to_string().as_str(), - ); + ui.storage.paths.savestate_file_path.push(format!( + "{}-{}.state{}", + prefix, ui.game_hash, ui.storage.save_state_slot + )); } pub fn load_saves(ui: &mut ui::Ui, netplay: &mut Option) {