optimizations #161
@ -38,17 +38,17 @@ use strerror::StrError;
|
|||||||
|
|
||||||
fn oserr(argv0: &str, e: Error) -> ExitCode {
|
fn oserr(argv0: &str, e: Error) -> ExitCode {
|
||||||
eprintln!("{}: {}", argv0, e.strerror());
|
eprintln!("{}: {}", argv0, e.strerror());
|
||||||
ExitCode::from(EX_OSERR as u8)
|
ExitCode::from(EX_OSERR)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ioerr(argv0: &str, e: Error) -> ExitCode {
|
fn ioerr(argv0: &str, e: Error) -> ExitCode {
|
||||||
eprintln!("{}: {}", argv0, e.strerror());
|
eprintln!("{}: {}", argv0, e.strerror());
|
||||||
ExitCode::from(EX_IOERR as u8)
|
ExitCode::from(EX_IOERR)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(s: &str) -> ExitCode {
|
fn usage(s: &str) -> ExitCode {
|
||||||
eprintln!("Usage: {} [-w word_size]", s);
|
eprintln!("Usage: {} [-w word_size]", s);
|
||||||
ExitCode::from(EX_USAGE as u8)
|
ExitCode::from(EX_USAGE)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> ExitCode {
|
fn main() -> ExitCode {
|
||||||
@ -88,7 +88,7 @@ fn main() -> ExitCode {
|
|||||||
|
|
||||||
loop {
|
loop {
|
||||||
match input.read(&mut buf) {
|
match input.read(&mut buf) {
|
||||||
Ok(0) => break ExitCode::from(EX_OK as u8), // read nothing; bye
|
Ok(0) => break ExitCode::from(EX_OK), // read nothing; bye
|
||||||
Ok(v) if v == wordsize => { // read full block; swab
|
Ok(v) if v == wordsize => { // read full block; swab
|
||||||
let (left, right) = buf.split_at(v/2);
|
let (left, right) = buf.split_at(v/2);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user