tsort: simplify code

This commit is contained in:
oech3
2026-06-01 16:35:37 +09:00
committed by Daniel Hofstetter
parent bcdd134352
commit 1bb616763a
+5 -21
View File
@@ -76,28 +76,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
#[cfg(not(windows))]
{
file = File::open(input)?;
// advise the OS we will access the data sequentially if available.
#[cfg(any(
target_os = "linux",
target_os = "android",
target_os = "fuchsia",
target_env = "uclibc",
target_os = "freebsd",
))]
{
use rustix::fs::{Advice, fadvise};
use std::os::unix::io::AsFd;
fadvise(
file.as_fd(),
0, // offset 0 => from the start of the file
None, // None => for the whole file
Advice::Sequential,
)
.ok();
}
}
// advise the OS we will access the data sequentially if available.
// offset 0 => from the start of the file. None => for the whole file.
#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))]
let _ = rustix::fs::fadvise(&file, 0, None, rustix::fs::Advice::Sequential);
let reader = BufReader::new(file);
process_input(reader, &mut g)?;
}