Date: Mon, 17 Dec 2018 15:19:48 +0000 (UTC) From: Maxim Sobolev <sobomax@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r342167 - stable/11/bin/dd Message-ID: <201812171519.wBHFJmBF023463@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sobomax Date: Mon Dec 17 15:19:48 2018 New Revision: 342167 URL: https://svnweb.freebsd.org/changeset/base/342167 Log: MFC r341257: improve speed of empty block detection. Modified: stable/11/bin/dd/dd.c stable/11/bin/dd/dd.h Directory Properties: stable/11/ (props changed) Modified: stable/11/bin/dd/dd.c ============================================================================== --- stable/11/bin/dd/dd.c Mon Dec 17 15:17:09 2018 (r342166) +++ stable/11/bin/dd/dd.c Mon Dec 17 15:19:48 2018 (r342167) @@ -474,7 +474,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; @@ -507,12 +507,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; Modified: stable/11/bin/dd/dd.h ============================================================================== --- stable/11/bin/dd/dd.h Mon Dec 17 15:17:09 2018 (r342166) +++ stable/11/bin/dd/dd.h Mon Dec 17 15:19:48 2018 (r342167) @@ -102,3 +102,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))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812171519.wBHFJmBF023463>