mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
Removes 'fast read' plumbing.
- The dd info page mentions a special fast-read framework if no conv=FLAG is specified (see bs=N) which I left space for. As it turns out, this is performed already so it does not need to be implemented.
This commit is contained in:
parent
06dcdc0f1f
commit
19996c10a9
1 changed files with 28 additions and 49 deletions
|
@ -843,17 +843,6 @@ fn read_helper<R: Read, W: Write>(i: &mut Input<R>, o: &mut Output<W>, bsize: us
|
||||||
{
|
{
|
||||||
// Local Predicate Fns -----------------------------------------------
|
// Local Predicate Fns -----------------------------------------------
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_fast_read<R: Read, W: Write>(i: &Input<R>, o: &Output<W>) -> bool
|
|
||||||
{
|
|
||||||
// TODO: Enable this once fast_reads are implemented
|
|
||||||
false &&
|
|
||||||
i.ibs == o.obs
|
|
||||||
&& !is_conv(i)
|
|
||||||
&& !is_block(i)
|
|
||||||
&& !is_unblock(i)
|
|
||||||
&& !i.cflags.swab
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
fn is_conv<R: Read>(i: &Input<R>) -> bool
|
fn is_conv<R: Read>(i: &Input<R>) -> bool
|
||||||
{
|
{
|
||||||
i.cflags.ctable.is_some()
|
i.cflags.ctable.is_some()
|
||||||
|
@ -882,45 +871,35 @@ fn read_helper<R: Read, W: Write>(i: &mut Input<R>, o: &mut Output<W>, bsize: us
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
if is_fast_read(&i, &o)
|
// Read
|
||||||
{
|
let mut buf = vec![BUF_INIT_BYTE; bsize];
|
||||||
// TODO: fast reads are copies performed
|
let mut rstat = match i.cflags.sync
|
||||||
// directly to output (without creating any buffers)
|
{
|
||||||
// as mentioned in the dd spec.
|
Some(ch) =>
|
||||||
unimplemented!()
|
i.fill_blocks(&mut buf, o.obs, ch)?,
|
||||||
}
|
_ =>
|
||||||
else
|
i.fill_consecutive(&mut buf)?,
|
||||||
{
|
};
|
||||||
// Read
|
// Return early if no data
|
||||||
let mut buf = vec![BUF_INIT_BYTE; bsize];
|
if rstat.reads_complete == 0 && rstat.reads_partial == 0
|
||||||
let mut rstat = match i.cflags.sync
|
{
|
||||||
{
|
return Ok((rstat,buf));
|
||||||
Some(ch) =>
|
}
|
||||||
i.fill_blocks(&mut buf, o.obs, ch)?,
|
|
||||||
_ =>
|
|
||||||
i.fill_consecutive(&mut buf)?,
|
|
||||||
};
|
|
||||||
// Return early if no data
|
|
||||||
if rstat.reads_complete == 0 && rstat.reads_partial == 0
|
|
||||||
{
|
|
||||||
return Ok((rstat,buf));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Perform any conv=x[,x...] options
|
// Perform any conv=x[,x...] options
|
||||||
if i.cflags.swab
|
if i.cflags.swab
|
||||||
{
|
{
|
||||||
perform_swab(&mut buf);
|
perform_swab(&mut buf);
|
||||||
}
|
}
|
||||||
if is_conv(&i) || is_block(&i) || is_unblock(&i)
|
if is_conv(&i) || is_block(&i) || is_unblock(&i)
|
||||||
{
|
{
|
||||||
let buf = conv_block_unblock_helper(buf, i, o, &mut rstat)?;
|
let buf = conv_block_unblock_helper(buf, i, o, &mut rstat)?;
|
||||||
Ok((rstat, buf))
|
Ok((rstat, buf))
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Ok((rstat, buf))
|
Ok((rstat, buf))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_io_lines(update: &ProgUpdate)
|
fn print_io_lines(update: &ProgUpdate)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue