From 69d615da622cecd93623fada829db949092d1a3e Mon Sep 17 00:00:00 2001 From: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Date: Fri, 29 Nov 2024 00:48:45 +1100 Subject: [PATCH] Optimize RustcCodegenFlags Use `&str` instead of `String`. --- src/flags.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/flags.rs b/src/flags.rs index a94743fc..a00fa3ea 100644 --- a/src/flags.rs +++ b/src/flags.rs @@ -5,16 +5,16 @@ use std::ffi::OsString; use std::path::Path; #[derive(Debug, PartialEq, Default)] -pub(crate) struct RustcCodegenFlags { - branch_protection: Option, - code_model: Option, +pub(crate) struct RustcCodegenFlags<'a> { + branch_protection: Option<&'a str>, + code_model: Option<&'a str>, no_vectorize_loops: bool, no_vectorize_slp: bool, - profile_generate: Option, - profile_use: Option, - control_flow_guard: Option, - lto: Option, - relocation_model: Option, + profile_generate: Option<&'a str>, + profile_use: Option<&'a str>, + control_flow_guard: Option<&'a str>, + lto: Option<&'a str>, + relocation_model: Option<&'a str>, embed_bitcode: Option, force_frame_pointers: Option, link_dead_code: Option, @@ -89,12 +89,12 @@ impl RustcCodegenFlags { } let (flag, value) = if let Some((flag, value)) = flag.split_once('=') { - (flag, Some(value.to_owned())) + (flag, Some(value)) } else { (flag, None) }; - fn flag_ok_or(flag: Option, msg: &'static str) -> Result { + fn flag_ok_or(flag: Option<&str>, msg: &'static str) -> Result<&str, Error> { flag.ok_or(Error::new(ErrorKind::InvalidFlag, msg)) }