Skip to content

Commit

Permalink
Optimize RustcCodegenFlags
Browse files Browse the repository at this point in the history
Use `&str` instead of `String`.
  • Loading branch information
NobodyXu authored Nov 28, 2024
1 parent afb6d60 commit 69d615d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ use std::ffi::OsString;
use std::path::Path;

#[derive(Debug, PartialEq, Default)]
pub(crate) struct RustcCodegenFlags {
branch_protection: Option<String>,
code_model: Option<String>,
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<String>,
profile_use: Option<String>,
control_flow_guard: Option<String>,
lto: Option<String>,
relocation_model: Option<String>,
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<bool>,
force_frame_pointers: Option<bool>,
link_dead_code: Option<bool>,
Expand Down Expand Up @@ -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<String>, msg: &'static str) -> Result<String, Error> {
fn flag_ok_or(flag: Option<&str>, msg: &'static str) -> Result<&str, Error> {
flag.ok_or(Error::new(ErrorKind::InvalidFlag, msg))
}

Expand Down

0 comments on commit 69d615d

Please sign in to comment.