From: Sage Weil Date: Fri, 15 May 2020 17:06:55 +0000 (-0500) Subject: common/FastCDC: simplify initial fingerprint calc X-Git-Tag: v16.1.0~2230^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c63871528972edafbc7c271046b2d65ff0662f2f;p=ceph.git common/FastCDC: simplify initial fingerprint calc Signed-off-by: Sage Weil --- diff --git a/src/common/FastCDC.cc b/src/common/FastCDC.cc index 0836aa6468b6..9c28f1e29dbc 100644 --- a/src/common/FastCDC.cc +++ b/src/common/FastCDC.cc @@ -83,22 +83,25 @@ void FastCDC::calc_chunks( size_t pos = 0; while (pos < len) { size_t cstart = pos; - uint64_t fp = 0; + // are we left with a <= min chunk? + if (len - pos <= (1ul << min_bits)) { + chunks->push_back(std::pair(pos, len - pos)); + break; + } + // skip forward to the min chunk size cut point (minus the window, so // we can initialize the rolling fingerprint). - pos = std::min(pos + (1 << min_bits) - window, len); + pos += (1 << min_bits) - window; // first fill the window - while (pos < std::min(window, len)) { + size_t max = pos + window; + while (pos < max) { fp = (fp << 1) ^ table[ptr[pos]]; ++pos; } - if (pos >= len) { - chunks->push_back(std::pair(cstart, pos - cstart)); - break; - } + ceph_assert(pos < len); // find an end marker if (_scan(ptr, pos,