Skip to content

Commit

Permalink
MFC r341257: improve speed of empty block detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax authored and sobomax committed Dec 17, 2018
1 parent 3460d74 commit 784236e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 3 additions & 7 deletions bin/dd/dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ void
dd_out(int force)
{
u_char *outp;
size_t cnt, i, n;
size_t cnt, n;
ssize_t nw;
static int warned;
int sparse;
Expand Down Expand Up @@ -545,12 +545,8 @@ dd_out(int force)
do {
sparse = 0;
if (ddflags & C_SPARSE) {
sparse = 1; /* Is buffer sparse? */
for (i = 0; i < cnt; i++)
if (outp[i] != 0) {
sparse = 0;
break;
}
/* Is buffer sparse? */
sparse = BISZERO(outp, cnt);
}
if (sparse && !force) {
pending += cnt;
Expand Down
4 changes: 4 additions & 0 deletions bin/dd/dd.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,7 @@ typedef struct {
#define C_PROGRESS 0x40000000

#define C_PARITY (C_PAREVEN | C_PARODD | C_PARNONE | C_PARSET)

#define BISZERO(p, s) ((s) > 0 && *((const char *)p) == 0 && !memcmp( \
(const void *)(p), (const void *) \
((const char *)p + 1), (s) - 1))

0 comments on commit 784236e

Please sign in to comment.