mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
tail: When tailing a file in bytes mode, seek directly to the specified byte
When tailing a file, as opposed to stdin, and we are tailing bytes rather than lines, we can seek the requested number of bytes from the end of the file. This side steps the whole `backwards_thru_file` file loop and blocks of reads. Fixes #833.
This commit is contained in:
+2
-5
@@ -336,11 +336,8 @@ fn bounded_tail(mut file: File, settings: &Settings) {
|
||||
}
|
||||
});
|
||||
},
|
||||
FilterMode::Bytes(mut count) => {
|
||||
backwards_thru_file(&mut file, size, &mut buf, &mut |_| {
|
||||
count -= 1;
|
||||
count == 0
|
||||
});
|
||||
FilterMode::Bytes(count) => {
|
||||
file.seek(SeekFrom::End(-(count as i64))).unwrap();
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user