@@ -246,7 +246,7 @@ class RmMTree : public RmMBase<RmMTree> {
246246 pattern_count += rr_in_block (block_begin, end_position);
247247 // boundary between the last full node and the leaf tail
248248 if (block_index > 0 && end_position > block_begin &&
249- previous_last_bit == 1 && bit (block_begin) == 0 ) {
249+ previous_last_bit == 1 && bit_impl (block_begin) == 0 ) {
250250 ++pattern_count;
251251 }
252252 return pattern_count;
@@ -710,7 +710,7 @@ class RmMTree : public RmMBase<RmMTree> {
710710 std::min (range_end, begin_block_end - 1 );
711711 for (size_t position = range_begin; position <= end_of_first_chunk;
712712 ++position) {
713- current_excess += bit (position) ? +1 : -1 ;
713+ current_excess += bit_impl (position) ? +1 : -1 ;
714714 if (current_excess < min_value) {
715715 min_value = current_excess;
716716 local_count = 1 ;
@@ -745,7 +745,7 @@ class RmMTree : public RmMBase<RmMTree> {
745745 int current_excess = 0 , min_value = INT_MAX , local_count = 0 ;
746746 for (size_t position = end_block_start; position <= range_end;
747747 ++position) {
748- current_excess += bit (position) ? +1 : -1 ;
748+ current_excess += bit_impl (position) ? +1 : -1 ;
749749 if (current_excess < min_value) {
750750 min_value = current_excess;
751751 local_count = 1 ;
@@ -970,6 +970,13 @@ class RmMTree : public RmMBase<RmMTree> {
970970 return bwdsearch_impl (position + 1 , -2 );
971971 }
972972
973+ /* *
974+ * @brief Read bit at position @p position (LSB-first across words).
975+ */
976+ inline int bit_impl (const size_t & position) const noexcept {
977+ return (bits[position >> 6 ] >> (position & 63 )) & 1u ;
978+ }
979+
973980 private:
974981 /* *
975982 * @brief Count "10" occurrences inside a 64-bit slice of given logical
@@ -1407,7 +1414,7 @@ class RmMTree : public RmMBase<RmMTree> {
14071414 pos += 16 ;
14081415 }
14091416 while (pos < end) {
1410- cur += bit (pos) ? +1 : -1 ;
1417+ cur += bit_impl (pos) ? +1 : -1 ;
14111418 if (cur == required_delta) {
14121419 return pos;
14131420 }
@@ -1440,7 +1447,7 @@ class RmMTree : public RmMBase<RmMTree> {
14401447
14411448 size_t pos = start;
14421449 while (pos < end && (pos & 7 )) {
1443- cur += bit (pos) ? +1 : -1 ;
1450+ cur += bit_impl (pos) ? +1 : -1 ;
14441451 if (cur == required_delta) {
14451452 if (out_total) {
14461453 *out_total = cur;
@@ -1481,7 +1488,7 @@ class RmMTree : public RmMBase<RmMTree> {
14811488 }
14821489
14831490 while (pos < end) {
1484- cur += bit (pos) ? +1 : -1 ;
1491+ cur += bit_impl (pos) ? +1 : -1 ;
14851492 if (cur == required_delta) {
14861493 if (out_total) {
14871494 *out_total = cur;
@@ -1530,7 +1537,7 @@ class RmMTree : public RmMBase<RmMTree> {
15301537 }
15311538
15321539 while (position < search_end) {
1533- current_excess += bit (position) ? 1 : -1 ;
1540+ current_excess += bit_impl (position) ? 1 : -1 ;
15341541 if (current_excess == required_delta) {
15351542 return position;
15361543 }
@@ -1656,14 +1663,14 @@ class RmMTree : public RmMBase<RmMTree> {
16561663 return npos;
16571664 }
16581665 const size_t bit_pos = pos_end - 1 ;
1659- cur_end -= bit (bit_pos) ? +1 : -1 ; // move one bit to the left
1666+ cur_end -= bit_impl (bit_pos) ? +1 : -1 ; // move one bit to the left
16601667 pos_end = bit_pos;
16611668 }
16621669#else
16631670 size_t last_boundary = npos;
16641671 int cur = 0 ;
16651672 for (size_t pos = block_begin; pos < boundary_max; ++pos) {
1666- cur += bit (pos) ? +1 : -1 ;
1673+ cur += bit_impl (pos) ? +1 : -1 ;
16671674 if (cur == required_delta) {
16681675 last_boundary = pos + 1 ;
16691676 }
@@ -1902,7 +1909,7 @@ class RmMTree : public RmMBase<RmMTree> {
19021909 if (block_end == seg_end) {
19031910 const int total = node_total_excess[node_index];
19041911 if (!allow_right_boundary && block_end > segment_base) {
1905- prefix_override = total - (bit (block_end - 1 ) ? +1 : -1 );
1912+ prefix_override = total - (bit_impl (block_end - 1 ) ? +1 : -1 );
19061913 } else {
19071914 prefix_override = total;
19081915 }
@@ -2202,13 +2209,6 @@ class RmMTree : public RmMBase<RmMTree> {
22022209 build (leaf_block_bits, max_overhead);
22032210 }
22042211
2205- /* *
2206- * @brief Read bit at position @p position (LSB-first across words).
2207- */
2208- inline int bit (const size_t & position) const noexcept {
2209- return (bits[position >> 6 ] >> (position & 63 )) & 1u ;
2210- }
2211-
22122212 /* *
22132213 * @brief Number of ones in node @p node_index computed from size and total
22142214 * excess.
@@ -2240,7 +2240,7 @@ class RmMTree : public RmMBase<RmMTree> {
22402240 }
22412241 // to byte alignment
22422242 while (range_begin <= range_end && (range_begin & 7 )) {
2243- current_excess += bit (range_begin) ? +1 : -1 ;
2243+ current_excess += bit_impl (range_begin) ? +1 : -1 ;
22442244 if (current_excess < min_value) {
22452245 min_value = current_excess;
22462246 count = 1 ;
@@ -2265,7 +2265,7 @@ class RmMTree : public RmMBase<RmMTree> {
22652265 }
22662266 // tail
22672267 while (range_begin <= range_end) {
2268- current_excess += bit (range_begin) ? +1 : -1 ;
2268+ current_excess += bit_impl (range_begin) ? +1 : -1 ;
22692269 if (current_excess < min_value) {
22702270 min_value = current_excess;
22712271 count = 1 ;
@@ -2335,7 +2335,7 @@ class RmMTree : public RmMBase<RmMTree> {
23352335 size_t position = range_begin;
23362336
23372337 while (position <= range_end && (position & 7 )) {
2338- current_excess += bit (position) ? +1 : -1 ;
2338+ current_excess += bit_impl (position) ? +1 : -1 ;
23392339 if (current_excess < min_value) {
23402340 min_value = current_excess;
23412341 }
@@ -2349,7 +2349,7 @@ class RmMTree : public RmMBase<RmMTree> {
23492349 position += 8 ;
23502350 }
23512351 while (position <= range_end) {
2352- current_excess += bit (position) ? +1 : -1 ;
2352+ current_excess += bit_impl (position) ? +1 : -1 ;
23532353 if (current_excess < min_value) {
23542354 min_value = current_excess;
23552355 }
@@ -2361,7 +2361,7 @@ class RmMTree : public RmMBase<RmMTree> {
23612361
23622362 // to byte alignment
23632363 while (position <= range_end && (position & 7 )) {
2364- current_excess += bit (position) ? +1 : -1 ;
2364+ current_excess += bit_impl (position) ? +1 : -1 ;
23652365 if (current_excess == min_value) {
23662366 if (--target_min_rank == 0 ) {
23672367 return position;
@@ -2392,7 +2392,7 @@ class RmMTree : public RmMBase<RmMTree> {
23922392
23932393 // tail
23942394 while (position <= range_end) {
2395- current_excess += bit (position) ? +1 : -1 ;
2395+ current_excess += bit_impl (position) ? +1 : -1 ;
23962396 if (current_excess == min_value) {
23972397 if (--target_min_rank == 0 ) {
23982398 return position;
@@ -2495,7 +2495,7 @@ class RmMTree : public RmMBase<RmMTree> {
24952495 // prefix at boundary_max = start_position-1:
24962496 // leaf_delta is prefix at start_position, subtract last step
24972497 (start_position > leaf_block_begin
2498- ? (leaf_delta - (bit (start_position - 1 ) ? +1 : -1 ))
2498+ ? (leaf_delta - (bit_impl (start_position - 1 ) ? +1 : -1 ))
24992499 : 0 ));
25002500 }
25012501
@@ -2516,7 +2516,7 @@ class RmMTree : public RmMBase<RmMTree> {
25162516
25172517 // to byte allignment
25182518 while (range_begin <= range_end && (range_begin & 7 )) {
2519- current_excess += bit (range_begin) ? +1 : -1 ;
2519+ current_excess += bit_impl (range_begin) ? +1 : -1 ;
25202520 if (current_excess < min_value) {
25212521 min_value = current_excess;
25222522 first_position = range_begin;
@@ -2538,7 +2538,7 @@ class RmMTree : public RmMBase<RmMTree> {
25382538
25392539 // tail
25402540 while (range_begin <= range_end) {
2541- current_excess += bit (range_begin) ? +1 : -1 ;
2541+ current_excess += bit_impl (range_begin) ? +1 : -1 ;
25422542 if (current_excess < min_value) {
25432543 min_value = current_excess;
25442544 first_position = range_begin;
@@ -2565,7 +2565,7 @@ class RmMTree : public RmMBase<RmMTree> {
25652565 first_position = npos;
25662566
25672567 while (range_begin <= range_end && (range_begin & 7 )) {
2568- current_excess += bit (range_begin) ? +1 : -1 ;
2568+ current_excess += bit_impl (range_begin) ? +1 : -1 ;
25692569 if (current_excess > max_value) {
25702570 max_value = current_excess;
25712571 first_position = range_begin;
@@ -2585,7 +2585,7 @@ class RmMTree : public RmMBase<RmMTree> {
25852585 }
25862586
25872587 while (range_begin <= range_end) {
2588- current_excess += bit (range_begin) ? +1 : -1 ;
2588+ current_excess += bit_impl (range_begin) ? +1 : -1 ;
25892589 if (current_excess > max_value) {
25902590 max_value = current_excess;
25912591 first_position = range_begin;
@@ -2649,7 +2649,7 @@ class RmMTree : public RmMBase<RmMTree> {
26492649 segment_size_bits[leaf_node_index] = segment_end - segment_begin;
26502650
26512651 if (segment_begin < segment_end) {
2652- node_first_bit[leaf_node_index] = bit (segment_begin);
2652+ node_first_bit[leaf_node_index] = bit_impl (segment_begin);
26532653 }
26542654
26552655 const auto & aggregates_table = LUT8 ();
@@ -2693,7 +2693,7 @@ class RmMTree : public RmMBase<RmMTree> {
26932693
26942694 // Tail < 8 bits
26952695 while (position < segment_end) {
2696- const uint8_t bit_value = bit (position);
2696+ const uint8_t bit_value = bit_impl (position);
26972697 if (previous_bit == 1 && bit_value == 0 ) {
26982698 pattern10_count++;
26992699 }
0 commit comments