File tree Expand file tree Collapse file tree
include/bitcoin/database/impl/primitives Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,6 +88,9 @@ TEMPLATE
8888constexpr bool CLASS::screened (sieve_t fingerprint) const NOEXCEPT
8989{
9090 using namespace system ;
91+ if constexpr (is_zero (limit))
92+ return true ;
93+
9194 const auto row = shift_right (sieve_, screen_bits);
9295 if (row == limit)
9396 {
@@ -114,6 +117,9 @@ TEMPLATE
114117constexpr bool CLASS::screen (sieve_t fingerprint) NOEXCEPT
115118{
116119 using namespace system ;
120+ if constexpr (is_zero (limit))
121+ return false ;
122+
117123 auto row = shift_right (sieve_, screen_bits);
118124 if (row == limit)
119125 {
Original file line number Diff line number Diff line change @@ -22,6 +22,26 @@ BOOST_AUTO_TEST_SUITE(sieve_tests)
2222
2323using namespace system;
2424
25+ BOOST_AUTO_TEST_CASE (sieve__screen__zeroed__always_screened)
26+ {
27+ // Ensure default/nop behavior.
28+ static_assert (sieve<0 , 0 >{}.screened (42 ));
29+ static_assert (sieve<1 , 0 >{}.screened (42 ));
30+ static_assert (!sieve<1 , 1 >{}.screened (42 ));
31+
32+ sieve<0 , 0 > sieve0{};
33+ BOOST_REQUIRE (sieve0.screened (42 ));
34+ BOOST_REQUIRE (!sieve0.screen (42 ));
35+
36+ sieve<1 , 0 > sieve1{};
37+ BOOST_REQUIRE (sieve1.screened (42 ));
38+ BOOST_REQUIRE (!sieve1.screen (42 ));
39+
40+ sieve<1 , 1 > sieve2{};
41+ BOOST_REQUIRE (!sieve2.screened (42 ));
42+ BOOST_REQUIRE (sieve2.screen (42 ));
43+ }
44+
2545#if defined(HAVE_SLOW_TESTS)
2646
2747BOOST_AUTO_TEST_CASE (sieve__screen__4_bits_forward__16_screens)
You can’t perform that action at this time.
0 commit comments