true, false: drop Vec for binary size and perf

This commit is contained in:
oech3
2026-03-07 16:07:15 +01:00
committed by Daniel Hofstetter
parent 38e2f15c4d
commit 59aa4d7bbc
2 changed files with 14 additions and 16 deletions
+7 -8
View File
@@ -3,20 +3,19 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
use clap::{Arg, ArgAction, Command};
use std::{ffi::OsString, io::Write};
use std::io::Write;
use uucore::translate;
// uucore::main does not support no-result
pub fn uumain(args: impl uucore::Args) -> i32 {
let args: Vec<OsString> = args.collect();
if args.len() != 2 {
pub fn uumain(mut args: impl uucore::Args) -> i32 {
// skip binary name
let (Some(flag), None) = (args.nth(1), args.next()) else {
return 1;
}
};
// args[0] is the name of the binary.
let error = if args[1] == "--help" {
let error = if flag == "--help" {
uu_app().print_help()
} else if args[1] == "--version" {
} else if flag == "--version" {
write!(std::io::stdout(), "{}", uu_app().render_version())
} else {
return 1;
+7 -8
View File
@@ -3,20 +3,19 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
use clap::{Arg, ArgAction, Command};
use std::{ffi::OsString, io::Write};
use std::io::Write;
use uucore::translate;
// uucore::main does not support no-result
pub fn uumain(args: impl uucore::Args) -> i32 {
let args: Vec<OsString> = args.collect();
if args.len() != 2 {
pub fn uumain(mut args: impl uucore::Args) -> i32 {
// skip binary name
let (Some(flag), None) = (args.nth(1), args.next()) else {
return 0;
}
};
// args[0] is the name of the binary.
let error = if args[1] == "--help" {
let error = if flag == "--help" {
uu_app().print_help()
} else if args[1] == "--version" {
} else if flag == "--version" {
write!(std::io::stdout(), "{}", uu_app().render_version())
} else {
return 0;