mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 20:17:45 +00:00
echo: reorder of match patterns
People write \n \t and \r \v much more often than other escape sequences, so it makes more sense to optimise for common case, as match scans from top to bottom.
This commit is contained in:
parent
7ebda2de44
commit
26ad240572
1 changed files with 4 additions and 4 deletions
|
@ -105,15 +105,15 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
prev_was_slash = false;
|
prev_was_slash = false;
|
||||||
match c {
|
match c {
|
||||||
'\\' => print!("\\"),
|
'\\' => print!("\\"),
|
||||||
|
'n' => print!("\n"),
|
||||||
|
'r' => print!("\r"),
|
||||||
|
't' => print!("\t"),
|
||||||
|
'v' => print!("\x0B"),
|
||||||
'a' => print!("\x07"),
|
'a' => print!("\x07"),
|
||||||
'b' => print!("\x08"),
|
'b' => print!("\x08"),
|
||||||
'c' => break,
|
'c' => break,
|
||||||
'e' => print!("\x1B"),
|
'e' => print!("\x1B"),
|
||||||
'f' => print!("\x0C"),
|
'f' => print!("\x0C"),
|
||||||
'n' => print!("\n"),
|
|
||||||
'r' => print!("\r"),
|
|
||||||
't' => print!("\t"),
|
|
||||||
'v' => print!("\x0B"),
|
|
||||||
'x' => {
|
'x' => {
|
||||||
let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 16);
|
let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 16);
|
||||||
if num_char_used == 0 {
|
if num_char_used == 0 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue