From 26ad2405723e0d985a0b36d53394ca7d2854bb02 Mon Sep 17 00:00:00 2001 From: Bulat Musin Date: Wed, 3 Jan 2018 18:14:50 +0300 Subject: [PATCH] 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. --- src/echo/echo.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/echo/echo.rs b/src/echo/echo.rs index 9e61a33a0..af195d1a0 100644 --- a/src/echo/echo.rs +++ b/src/echo/echo.rs @@ -105,15 +105,15 @@ pub fn uumain(args: Vec) -> i32 { prev_was_slash = false; match c { '\\' => print!("\\"), + 'n' => print!("\n"), + 'r' => print!("\r"), + 't' => print!("\t"), + 'v' => print!("\x0B"), 'a' => print!("\x07"), 'b' => print!("\x08"), 'c' => break, 'e' => print!("\x1B"), 'f' => print!("\x0C"), - 'n' => print!("\n"), - 'r' => print!("\r"), - 't' => print!("\t"), - 'v' => print!("\x0B"), 'x' => { let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 16); if num_char_used == 0 {