1
Fork 0

Remove unnecessary 0 link args optimization

This commit is contained in:
Mads Marquart 2024-11-24 01:23:19 +01:00
parent cb6f8fa422
commit 6bbf832cf2

View file

@ -183,15 +183,7 @@ fn verbatim_args<L: Linker + ?Sized>(
} }
/// Add underlying linker arguments to C compiler command, by wrapping them in /// Add underlying linker arguments to C compiler command, by wrapping them in
/// `-Wl` or `-Xlinker`. /// `-Wl` or `-Xlinker`.
fn convert_link_args_to_cc_args( fn convert_link_args_to_cc_args(cmd: &mut Command, args: impl IntoIterator<Item: AsRef<OsStr>>) {
cmd: &mut Command,
args: impl IntoIterator<Item: AsRef<OsStr>, IntoIter: ExactSizeIterator>,
) {
let args = args.into_iter();
if args.len() == 0 {
return;
}
let mut combined_arg = OsString::from("-Wl"); let mut combined_arg = OsString::from("-Wl");
for arg in args { for arg in args {
// If the argument itself contains a comma, we need to emit it // If the argument itself contains a comma, we need to emit it
@ -220,10 +212,7 @@ fn convert_link_args_to_cc_args(
} }
/// Arguments for the underlying linker. /// Arguments for the underlying linker.
/// Add options to pass them through cc wrapper if `Linker` is a cc wrapper. /// Add options to pass them through cc wrapper if `Linker` is a cc wrapper.
fn link_args<L: Linker + ?Sized>( fn link_args<L: Linker + ?Sized>(l: &mut L, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut L {
l: &mut L,
args: impl IntoIterator<Item: AsRef<OsStr>, IntoIter: ExactSizeIterator>,
) -> &mut L {
if !l.is_cc() { if !l.is_cc() {
verbatim_args(l, args); verbatim_args(l, args);
} else { } else {
@ -257,7 +246,7 @@ macro_rules! generate_arg_methods {
verbatim_args(self, iter::once(arg)) verbatim_args(self, iter::once(arg))
} }
#[allow(unused)] #[allow(unused)]
pub(crate) fn link_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>, IntoIter: ExactSizeIterator>) -> &mut Self { pub(crate) fn link_args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) -> &mut Self {
link_args(self, args) link_args(self, args)
} }
#[allow(unused)] #[allow(unused)]