From f8e04c562b59fbdf2dd1a2a4b353d0d7e51c8777 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:36:19 -0500 Subject: [PATCH] refactor/sort ~ polish spelling (comments, names, and exceptions) --- src/uu/sort/BENCHMARKING.md | 4 +++- src/uu/sort/src/sort.rs | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/uu/sort/BENCHMARKING.md b/src/uu/sort/BENCHMARKING.md index 560d6b438..77186318a 100644 --- a/src/uu/sort/BENCHMARKING.md +++ b/src/uu/sort/BENCHMARKING.md @@ -1,5 +1,7 @@ # Benchmarking sort + + Most of the time when sorting is spent comparing lines. The comparison functions however differ based on which arguments are passed to `sort`, therefore it is important to always benchmark multiple scenarios. This is an overview over what was benchmarked, and if you make changes to `sort`, you are encouraged to check @@ -96,7 +98,7 @@ When invoked with -c, we simply check if the input is already ordered. The input Try to run the above benchmarks by piping the input through stdin (standard input) and redirect the output through stdout (standard output): -- Remove the input file from the arguments and add `cat [inputfile] | ` at the beginning. +- Remove the input file from the arguments and add `cat [input_file] | ` at the beginning. - Remove `-o output.txt` and add `> output.txt` at the end. Example: `hyperfine "target/release/coreutils sort shuffled_numbers.txt -n -o output.txt"` becomes diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index a3b79e5d7..ab3b06451 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -11,7 +11,8 @@ // https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sort.html // https://www.gnu.org/software/coreutils/manual/html_node/sort-invocation.html -// spell-checker:ignore (ToDO) outfile nondictionary +// spell-checker:ignore (misc) HFKJFK Mbdfhn + #[macro_use] extern crate uucore; @@ -143,7 +144,7 @@ pub struct GlobalSettings { ignore_non_printing: bool, merge: bool, reverse: bool, - outfile: Option, + output_file: Option, stable: bool, unique: bool, check: bool, @@ -187,7 +188,7 @@ impl GlobalSettings { } fn out_writer(&self) -> BufWriter> { - match self.outfile { + match self.output_file { Some(ref filename) => match File::create(Path::new(&filename)) { Ok(f) => BufWriter::new(Box::new(f) as Box), Err(e) => { @@ -211,7 +212,7 @@ impl Default for GlobalSettings { ignore_non_printing: false, merge: false, reverse: false, - outfile: None, + output_file: None, stable: false, unique: false, check: false, @@ -1168,7 +1169,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { settings.ignore_blanks = matches.is_present(OPT_IGNORE_BLANKS); - settings.outfile = matches.value_of(OPT_OUTPUT).map(String::from); + settings.output_file = matches.value_of(OPT_OUTPUT).map(String::from); settings.reverse = matches.is_present(OPT_REVERSE); settings.stable = matches.is_present(OPT_STABLE); settings.unique = matches.is_present(OPT_UNIQUE);