mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 21:47:46 +00:00
head: use std::io::copy() with TakeLines reader
Replace the custom `split::walk_lines()` function with a call to `std::io::copy()`, using a new `TakeLines` reader as the source and `stdout` as the destination. The `TakeLines` reader is an adaptor that scans the bytes being read for line ending characters and stops the reading after a given number of lines has been read (similar to the `std::io::Take` adaptor). This change * makes the `read_n_lines()` function more concise, * allows it to mirror the implementation of `read_n_bytes()`, * increases the speed of `head -n NUM`.
This commit is contained in:
parent
c43436d50a
commit
858b0a9e9f
6 changed files with 146 additions and 82 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2507,6 +2507,7 @@ name = "uu_head"
|
|||
version = "0.0.7"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"memchr 2.4.0",
|
||||
"uucore",
|
||||
"uucore_procs",
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue