From 264cce31397ddba8c887610e06c2d747a0c36724 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 21 May 2020 10:36:28 -0500 Subject: [PATCH] common/FastCDC: better behavior if TARGET_WINDOW_BITS==0 Skip the middle scan call entirely in that case. Signed-off-by: Sage Weil --- src/common/FastCDC.cc | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/common/FastCDC.cc b/src/common/FastCDC.cc index 9576124619d..70358e9782e 100644 --- a/src/common/FastCDC.cc +++ b/src/common/FastCDC.cc @@ -155,18 +155,21 @@ void FastCDC::calc_chunks( ceph_assert(pos < len); // find an end marker - if (_scan(&p, &pp, &pe, pos, // for the first "small" region - std::min(len, - cstart + (1 << (target_bits - TARGET_WINDOW_BITS))), - fp, small_mask, table) && - _scan(&p, &pp, &pe, pos, // for the middle range (close to our target) - std::min(len, - cstart + (1 << (target_bits + TARGET_WINDOW_BITS))), - fp, target_mask, table) && - _scan(&p, &pp, &pe, pos, // we're past target, use large_mask! - std::min(len, - cstart + (1 << max_bits)), - fp, large_mask, table)) ; + if ( + // for the first "small" region + _scan(&p, &pp, &pe, pos, + std::min(len, cstart + (1 << (target_bits - TARGET_WINDOW_BITS))), + fp, small_mask, table) && + // for the middle range (close to our target) + (TARGET_WINDOW_BITS == 0 || + _scan(&p, &pp, &pe, pos, + std::min(len, cstart + (1 << (target_bits + TARGET_WINDOW_BITS))), + fp, target_mask, table)) && + // we're past target, use large_mask! + _scan(&p, &pp, &pe, pos, + std::min(len, + cstart + (1 << max_bits)), + fp, large_mask, table)) ; chunks->push_back(std::pair(cstart, pos - cstart)); }