]> git.ipfire.org Git - thirdparty/coreutils.git/commit
cp: omit some needless lseek calls
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 7 Aug 2025 22:42:23 +0000 (15:42 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 8 Aug 2025 03:20:04 +0000 (20:20 -0700)
commit26bf557e3f79352d36df0a6de5908e656a4f1dc4
tree6a0cca971b7f8730f793b1de5335e1f966363548
parent2f2adb294eb24e0754c2341fb3a699088956a673
cp: omit some needless lseek calls

The sparse code sometimes issued multiple lseeks against the
same file without doing anything in betwee.  Optimize them away
by keeping track of the last hole output, in a way that
crosses the sparse_copy function call boundary.
* src/copy.c (sparse_copy): New arg hole_size, replacing old args
scan_holes and last_write_made_hole.  All callers changed.
(sparse_copy, lseek_copy): Do not create hole at
end; let the caller deal with it.  All callers changed.
(lseek_copy): New args hole_size and total_n_read.  Caller changed.
(copy_reg): Create hole at end for both lseek_copy and sparse_copy.
src/copy.c