diff --git a/include/sdsl/bit_vector_il.hpp b/include/sdsl/bit_vector_il.hpp index 9ebf63eba..8d63fd3f6 100644 --- a/include/sdsl/bit_vector_il.hpp +++ b/include/sdsl/bit_vector_il.hpp @@ -130,7 +130,7 @@ class bit_vector_il size_type cum_sum = 0; size_type sample_rate = t_bs/64; for (size_type i=0, sample_cnt=sample_rate; i < blocks; ++i, ++sample_cnt) { - if (sample_cnt == sample_rate) { + if (sample_cnt == sample_rate) { // TODO get rid of this branch m_data[j] = cum_sum; sample_cnt = 0; j++; diff --git a/include/sdsl/bp_support_sada.hpp b/include/sdsl/bp_support_sada.hpp index 997d94ddc..55f23315d 100644 --- a/include/sdsl/bp_support_sada.hpp +++ b/include/sdsl/bp_support_sada.hpp @@ -369,7 +369,7 @@ class bp_support_sada // calculate min/max excess values of the small blocks and medium blocks difference_type min_ex = 1, max_ex = -1, curr_rel_ex = 0, curr_abs_ex = 0; for (size_type i=0; i < m_size; ++i) { - if ((*bp)[i]) + if ((*bp)[i]) // TODO This is not good ++curr_rel_ex; else --curr_rel_ex; @@ -397,9 +397,9 @@ class bp_support_sada for (size_type v = m_med_block_min_max.size()/2 - 1; !is_root(v); --v) { size_type p = parent(v); - if (min_value(v) < min_value(p)) // update minimum + if (min_value(v) < min_value(p)) // update minimum TODO branch can be avoided m_med_block_min_max[2*p] = m_med_block_min_max[2*v]; - if (max_value(v) > max_value(p)) // update maximum + if (max_value(v) > max_value(p)) // update maximum TODO branch can be avoided m_med_block_min_max[2*p+1] = m_med_block_min_max[2*v+1]; } } @@ -648,7 +648,7 @@ class bp_support_sada l_sblock = 1; } for (size_type i=l_sblock; i <= r_sblock; ++i) { - if ((e = (excess(i*t_sml_blk-1) + sml_min_value(i))) <= min_ex) { + if ((e = (excess(i*t_sml_blk-1) + sml_min_value(i))) <= min_ex) { //TODO branch can be avoided pos_min_block = i; min_ex = e; } diff --git a/include/sdsl/coder_comma.hpp b/include/sdsl/coder_comma.hpp index afd095c63..3b6caa9db 100644 --- a/include/sdsl/coder_comma.hpp +++ b/include/sdsl/coder_comma.hpp @@ -258,7 +258,7 @@ inline uint64_t comma::decode(const uint64_t* data, digit = (uint32_t)bits::read_int_and_move(data, offset, t_width)); //and read next digit //now decide how to handle value value = (t_sumup) ? value + v : v; - if (t_inc) *(it++) = value; + if (t_inc) *(it++) = value; // TODO can be done without the branch } return value; } diff --git a/include/sdsl/coder_elias_delta.hpp b/include/sdsl/coder_elias_delta.hpp index 2a72a352f..702ff0ff3 100644 --- a/include/sdsl/coder_elias_delta.hpp +++ b/include/sdsl/coder_elias_delta.hpp @@ -161,7 +161,7 @@ bool elias_delta::encode(const int_vector& v, int_vector& z) uint64_t w; const uint64_t zero_val = v.width() < 64 ? (1ULL)<= size_of_part) { + if (left[i]/2 >= size_of_part) { // TODO possible without conditional text_rec[(left[i]/2)-size_of_part] = order; } } std::string filename_text_rec_part2 = tmp_file(filename_sa, "_text_rec_part2"+util::to_string(recursion)); size_t pos = 0; for (size_t i=0; i0) { + if (text_rec[i]>0) { // TODO possible without conditional text_rec[pos++] = text_rec[i]; } } @@ -392,23 +392,24 @@ void _construct_sa_se(int_vector_type& text, std::string filename_sa, uint64_t s text_rec.resize(size_of_part); util::_set_zero_bits(text_rec); order = 0; + // TODO code duplication !! for (size_t i=number_of_lms_strings-1; i0) { + if (text_rec[i]>0) { // TODO possible without conditional text_rec[pos++] = text_rec[i]; } } text_rec.resize(number_of_lms_strings); int_vector_buffer<> buf(filename_text_rec_part2, std::ios::in, 1024*1024); - for (size_t i=0; i0) { + if (text_rec[i]>0) { // TODO possible without conditional text_rec[pos++] = text_rec[i]; } } diff --git a/include/sdsl/csa_alphabet_strategy.hpp b/include/sdsl/csa_alphabet_strategy.hpp index ec49cc8cd..667dfc831 100644 --- a/include/sdsl/csa_alphabet_strategy.hpp +++ b/include/sdsl/csa_alphabet_strategy.hpp @@ -269,7 +269,7 @@ class succinct_byte_alphabet assert(1 == D[0]); // null-byte should occur exactly once m_sigma = 0; for (int i=0; i<256; ++i) - if (D[i]) { + if (D[i]) { // TODO possible without conditional tmp_char[i] = 1; // mark occurring character D[m_sigma] = D[i]; // compactify m_C ++m_sigma; diff --git a/include/sdsl/csa_sampling_strategy.hpp b/include/sdsl/csa_sampling_strategy.hpp index c04cd8a17..eda72ab98 100644 --- a/include/sdsl/csa_sampling_strategy.hpp +++ b/include/sdsl/csa_sampling_strategy.hpp @@ -85,7 +85,7 @@ class _sa_order_sampling : public int_vector for (size_type i=0, cnt_mod=sample_dens, cnt_sum=0; i < n; ++i, ++cnt_mod) { size_type sa = sa_buf[i]; - if (sample_dens == cnt_mod) { + if (sample_dens == cnt_mod) { // TODO possible without conditional cnt_mod = 0; (*this)[cnt_sum++] = sa; } @@ -151,7 +151,7 @@ class _text_order_sampling : public int_vector for (size_type i=0, sa_cnt=0; i < n; ++i) { size_type sa = sa_buf[i]; - if (0 == (sa % sample_dens)) { + if (0 == (sa % sample_dens)) { // TODO possible without conditional marked[i] = 1; (*this)[sa_cnt++] = sa; } @@ -299,18 +299,18 @@ class _bwt_sampling : public int_vector size_type sa = sa_buf[i]; char_type bwt = bwt_buf[i]; if (0 == (sa % sample_dens)) { - marked[i] = 1; - ++sa_cnt; + marked[i] = 1; // TODO same as below + ++sa_cnt; // TODO same as below } else if (char_map.find(bwt) != char_map.end()) { - marked[i] = 1; - ++sa_cnt; + marked[i] = 1; // TODO same as above + ++sa_cnt; // TODO same as above } } this->resize(sa_cnt); sa_cnt = 0; for (size_type i=0; i < n; ++i) { size_type sa = sa_buf[i]; - if (marked[i]) { + if (marked[i]) { // TODO possible without conditional (*this)[sa_cnt++] = sa; } } diff --git a/include/sdsl/cst_sada.hpp b/include/sdsl/cst_sada.hpp index 22e7d4a41..bd6fd0c04 100644 --- a/include/sdsl/cst_sada.hpp +++ b/include/sdsl/cst_sada.hpp @@ -157,9 +157,9 @@ class cst_sada util::set_to_value(m_bp, 0); size_type idx=0; for (cst_sct3<>::const_iterator it=temp_cst.begin(), end=temp_cst.end(); it!=end; ++it) { - if (1 == it.visit()) + if (1 == it.visit()) // TODO possible without conditional m_bp[idx] = 1; - if (temp_cst.is_leaf(*it) and temp_cst.root()!= *it) + if (temp_cst.is_leaf(*it) and temp_cst.root()!= *it) // TODO possible without conditional ++idx; ++idx; } diff --git a/include/sdsl/dac_vector.hpp b/include/sdsl/dac_vector.hpp index ad11886b7..fb3601ac2 100644 --- a/include/sdsl/dac_vector.hpp +++ b/include/sdsl/dac_vector.hpp @@ -234,7 +234,7 @@ dac_vector::dac_vector(const Container& c) t = sum_blocks; sum_blocks += m_level_pointer_and_rank[i]; m_level_pointer_and_rank[i] = t; - if (sum_blocks > t) { + if (sum_blocks > t) { // TODO possible without conditional ++m_max_level; last_block_size = sum_blocks - t; } @@ -311,7 +311,7 @@ dac_vector::dac_vector(int_vector_buffer& v_buf) t = sum_blocks; sum_blocks += m_level_pointer_and_rank[i]; m_level_pointer_and_rank[i] = t; - if (sum_blocks > t) { + if (sum_blocks > t) { // TODO possible without conditional ++m_max_level; last_block_size = sum_blocks - t; } diff --git a/include/sdsl/enc_vector.hpp b/include/sdsl/enc_vector.hpp index a4731c3a9..6569de8f4 100644 --- a/include/sdsl/enc_vector.hpp +++ b/include/sdsl/enc_vector.hpp @@ -222,7 +222,7 @@ enc_vector::enc_vector(const Container& c) v2 = *it; if (!no_sample) { // add a sample no_sample = get_sample_dens(); - if (max_sample_value < v2) max_sample_value = v2; + if (max_sample_value < v2) max_sample_value = v2; // TODO possible without conditional ++samples; } else { z_size += t_coder::encoding_length(v2-v1); @@ -242,11 +242,11 @@ enc_vector::enc_vector(const Container& c) size_type no_sample=0; for (it = c.begin(); it != end; ++it, --no_sample) { v2 = *it; - if (!no_sample) { // add a sample + if (!no_sample) { // add a sample // TODO possible without conditional no_sample = get_sample_dens(); *sv_it = v2; ++sv_it; *sv_it = z_size; ++sv_it; - } else { + } else { // TODO possible without conditional x = v2-v1; z_size += t_coder::encoding_length(x); } @@ -289,7 +289,7 @@ enc_vector::enc_vector(int_vector_buffer& v_ v2 = v_buf[i]; if (!no_sample) { // is sample no_sample = sd; - if (max_sample_value < v2) max_sample_value = v2; + if (max_sample_value < v2) max_sample_value = v2; // TODO possible without conditional ++samples; } else { z_size += t_coder::encoding_length(v2-v1); diff --git a/include/sdsl/fast_cache.hpp b/include/sdsl/fast_cache.hpp index 09c4c3591..6fe2d7c5a 100644 --- a/include/sdsl/fast_cache.hpp +++ b/include/sdsl/fast_cache.hpp @@ -21,10 +21,10 @@ struct fast_cache { // Returns true if the request i is cached and // x is set to the answer of request i bool exists(size_type i, size_type& x) { - if (m_table[(i&CACHE_SIZE)<<1 ] == i) { + if (m_table[(i&CACHE_SIZE)<<1 ] == i) { // TODO possible without conditional x = m_table[((i&CACHE_SIZE)<<1) + 1 ]; return true; - } else + } else // TODO possible without conditional return false; } // Writes the answer for request i to the cache diff --git a/include/sdsl/int_vector.hpp b/include/sdsl/int_vector.hpp index b61795c8b..e928eadb1 100644 --- a/include/sdsl/int_vector.hpp +++ b/include/sdsl/int_vector.hpp @@ -304,7 +304,7 @@ class int_vector int_vector(std::initializer_list il) : int_vector() { resize(il.size()); size_type idx = 0; -for (auto x : il) { + for (auto x : il) { (*this)[idx++] = x; } } @@ -1113,7 +1113,7 @@ template inline typename std::enable_if::value, std::ostream&>::type operator<<(std::ostream& os, const t_bv& bv) { -for (auto b : bv) { + for (auto b : bv) { os << b; } return os; diff --git a/include/sdsl/inv_perm_support.hpp b/include/sdsl/inv_perm_support.hpp index 8ff593504..1cf50382c 100644 --- a/include/sdsl/inv_perm_support.hpp +++ b/include/sdsl/inv_perm_support.hpp @@ -96,7 +96,7 @@ class inv_perm_support back_pointer = j; } } - if (all_steps > t_s) { + if (all_steps > t_s) { // TODO possible without conditional marked[i] = 1; max_back_pointer = std::max(max_back_pointer, back_pointer); } @@ -125,7 +125,7 @@ class inv_perm_support back_pointer = j; } } - if (all_steps > t_s) { + if (all_steps > t_s) { // TODO possible without conditional m_back_pointer[m_rank_marked(i)] = back_pointer; } } diff --git a/include/sdsl/lcp_byte.hpp b/include/sdsl/lcp_byte.hpp index 8aa544e64..0ef4191a4 100644 --- a/include/sdsl/lcp_byte.hpp +++ b/include/sdsl/lcp_byte.hpp @@ -98,9 +98,9 @@ class lcp_byte size_type l=0, max_l=0, max_big_idx=0, big_sum=0; for (size_type i=0; i < m_small_lcp.size(); ++i) { - if ((l=lcp_buf[i]) < 255) { + if ((l=lcp_buf[i]) < 255) { // TODO possible without conditional m_small_lcp[i] = l; - } else { + } else { // TODO possible without conditional m_small_lcp[i] = 255; if (l > max_l) max_l = l; max_big_idx = i; @@ -111,7 +111,7 @@ class lcp_byte m_big_lcp_idx = int_vector<>(big_sum, 0, bits::hi(max_big_idx)+1); for (size_type i=0,ii=0; i= 255) { + if ((l=lcp_buf[i]) >= 255) { // TODO possible without conditional m_big_lcp[ii] = l; m_big_lcp_idx[ii] = i; ++ii; diff --git a/include/sdsl/lcp_support_tree2.hpp b/include/sdsl/lcp_support_tree2.hpp index 0dcec7a24..1d2529b82 100644 --- a/include/sdsl/lcp_support_tree2.hpp +++ b/include/sdsl/lcp_support_tree2.hpp @@ -227,7 +227,7 @@ void construct_first_child_and_lf_lcp(int_vector_buffer<>& lcp_buf, val = M; big_lcp_out.write((char*)&y, sizeof(y)); ++fc_cnt_big; - if (y > max_lcp) max_lcp = y; + if (y > max_lcp) max_lcp = y; // TODO why not std::max?? } else { val = M-1; ++fc_cnt_big2; diff --git a/include/sdsl/lcp_wt.hpp b/include/sdsl/lcp_wt.hpp index dd6bc9d76..a6fc657b3 100644 --- a/include/sdsl/lcp_wt.hpp +++ b/include/sdsl/lcp_wt.hpp @@ -105,9 +105,9 @@ class lcp_wt { int_vector<8> small_lcp = int_vector<8>(n); for (size_type i=0; i < n; ++i) { - if ((l=lcp_buf[i]) < 255) { + if ((l=lcp_buf[i]) < 255) { // TODO possible without conditional small_lcp[i] = l; - } else { + } else { // TODO possible without conditional small_lcp[i] = 255; if (l > max_l) max_l = l; ++big_sum; @@ -124,7 +124,7 @@ class lcp_wt m_big_lcp = int_vector<>(big_sum, 0, bits::hi(max_l)+1); { for (size_type i=0, ii=0; i < n; ++i) { - if (lcp_buf[i] >= 255) { + if (lcp_buf[i] >= 255) { // TODO possible without conditional m_big_lcp[ ii++ ] = lcp_buf[i]; } } diff --git a/include/sdsl/memory_management.hpp b/include/sdsl/memory_management.hpp index 6804a80ad..f9efd73a3 100644 --- a/include/sdsl/memory_management.hpp +++ b/include/sdsl/memory_management.hpp @@ -116,7 +116,7 @@ class memory_monitor for (auto events : m.completed_events) { for (auto alloc : events.allocations) { if (max < alloc.usage) { - max = alloc.usage; + max = alloc.usage; // TODO why not std::max? } } } diff --git a/include/sdsl/nearest_neighbour_dictionary.hpp b/include/sdsl/nearest_neighbour_dictionary.hpp index 6f3880b5f..316a69b09 100644 --- a/include/sdsl/nearest_neighbour_dictionary.hpp +++ b/include/sdsl/nearest_neighbour_dictionary.hpp @@ -87,8 +87,8 @@ class nearest_neighbour_dictionary // get maximal distance between to ones in the bit vector // speed this up by broadword computing for (size_type i=0, last_one_pos_plus_1=0; i < v.size(); ++i) { - if (v[i]) { - if (i+1-last_one_pos_plus_1 > max_distance_between_two_ones) + if (v[i]) { // TODO possible without conditional + if (i+1-last_one_pos_plus_1 > max_distance_between_two_ones) // TODO possible without conditional max_distance_between_two_ones = i+1-last_one_pos_plus_1; last_one_pos_plus_1 = i+1; ++ones; @@ -108,10 +108,10 @@ class nearest_neighbour_dictionary for (size_type i=0, last_one_pos=0; i < v.size(); ++i) { if (v[i]) { ++ones; - if ((ones % t_sample_dens) == 0) { // insert absolute samples + if ((ones % t_sample_dens) == 0) { // insert absolute samples // TODO possible without conditional m_abs_samples[ones/t_sample_dens] = i; m_contains_abs_sample[i/t_sample_dens] = 1; - } else { + } else { // TODO possible without conditional m_differences[ones - ones/t_sample_dens - 1] = i - last_one_pos; } last_one_pos = i; diff --git a/include/sdsl/qsufsort.hpp b/include/sdsl/qsufsort.hpp index 0091849d9..b92f4f207 100644 --- a/include/sdsl/qsufsort.hpp +++ b/include/sdsl/qsufsort.hpp @@ -339,7 +339,7 @@ class sorter cc=(cc&mm)<capacity()>>6) ; ++i) { - if (!(i&0x7)) {// if i%8==0 + if (!(i&0x7)) {// if i%8==0 // TODO possible without conditional j += 2; m_basic_block[j-1] = second_level_cnt; m_basic_block[j] = m_basic_block[j-2] + sum; second_level_cnt = sum = 0; - } else { + } else { // TODO possible without conditional second_level_cnt |= sum<<(63-9*(i&0x7));// 54, 45, 36, 27, 18, 9, 0 } sum += trait_type::args_in_the_word(*(++data), carry); } - if (i&0x7) { // if i%8 != 0 + if (i&0x7) { // if i%8 != 0 // TODO possible without conditional second_level_cnt |= sum << (63-9*(i&0x7)); m_basic_block[j+1] = second_level_cnt; - } else { // if i%8 == 0 + } else { // if i%8 == 0 // TODO possible without conditional j += 2; m_basic_block[j-1] = second_level_cnt; m_basic_block[j] = m_basic_block[j-2] + sum; diff --git a/include/sdsl/rmq_support_sparse_table.hpp b/include/sdsl/rmq_support_sparse_table.hpp index a726ec269..762132134 100644 --- a/include/sdsl/rmq_support_sparse_table.hpp +++ b/include/sdsl/rmq_support_sparse_table.hpp @@ -87,7 +87,7 @@ class rmq_support_sparse_table m_table[i] = int_vector<>(n-(1<<(i+1))+1, 0, i+1); } for (size_type i=0; i t_bs/2) + if (bt_array[j] > t_bs/2) // TODO possible without conditional ++gt_half_t_bs; } if (gt_half_t_bs > (t_k/2)) { diff --git a/include/sdsl/rrr_vector_15.hpp b/include/sdsl/rrr_vector_15.hpp index d64d3871d..0fabc2f24 100644 --- a/include/sdsl/rrr_vector_15.hpp +++ b/include/sdsl/rrr_vector_15.hpp @@ -75,9 +75,9 @@ class binomial15 ++cnt; ++class_cnt; } while (next_permutation(b.begin(), b.end())); - if (class_cnt == 1) + if (class_cnt == 1) // TODO possible without conditional m_space_for_bt[i] = 0; - else + else // TODO possible without conditional m_space_for_bt[i] = bits::hi(class_cnt)+1; } if (n == 15) { diff --git a/include/sdsl/sd_vector.hpp b/include/sdsl/sd_vector.hpp index 8e6c14eca..4bfce6d92 100644 --- a/include/sdsl/sd_vector.hpp +++ b/include/sdsl/sd_vector.hpp @@ -531,10 +531,10 @@ class select_0_support_sd w = m_v->high.get_int(i, 64); rank1 += bits::cnt(w); rank_0 = (i+64)-rank1; - if (rank1 > 0 and (w>>63)&1) { + if (rank1 > 0 and (w>>63)&1) { // TODO possible without conditional uint64_t pos = rank_0*bs + m_v->low[rank1-1]; // pos of last one (of previous block in B z = pos + 1 - rank1; - } else { + } else { // TODO possible without conditional z = rank_0*bs - rank1; } while (sel0 <= z and sel0 <= zeros) { diff --git a/include/sdsl/select_support_mcl.hpp b/include/sdsl/select_support_mcl.hpp index 573b989ac..1a6e8c5f1 100644 --- a/include/sdsl/select_support_mcl.hpp +++ b/include/sdsl/select_support_mcl.hpp @@ -300,7 +300,7 @@ void select_support_mcl::init_fast(const bit_vector* v) size_type pos_of_last_arg_in_the_block = arg_position[last_k64-65]; for (size_type i=arg_position[last_k64-65]+1, j=last_k64-65; i < v->size() and j < SUPER_BLOCK_SIZE; ++i) - if (select_support_trait::found_arg(i, *v)) { + if (select_support_trait::found_arg(i, *v)) { // TODO possible without conditional pos_of_last_arg_in_the_block = i; ++j; } @@ -339,7 +339,7 @@ void select_support_mcl::init_fast(const bit_vector* v) if (m_longsuperblock == nullptr) m_longsuperblock = new int_vector<0>[sb+1]; // create longsuperblock m_longsuperblock[sb_cnt] = int_vector<0>(SUPER_BLOCK_SIZE, 0, bits::hi(v->size()-1) + 1); for (size_type i=arg_position[0],k=0; i < v->size(); ++i) { - if (select_support_trait::found_arg(i, *v)) { + if (select_support_trait::found_arg(i, *v)) { // TODO possible without conditional m_longsuperblock[sb_cnt][k++] = i; } } @@ -451,9 +451,9 @@ auto select_support_mcl::serialize(std::ostream& out, structure_t size_type written_bytes_long = 0; size_type written_bytes_mini = 0; for (size_type i=0; i < sb; ++i) - if (!mini_or_long.empty() and !mini_or_long[i]) { + if (!mini_or_long.empty() and !mini_or_long[i]) { // TODO possible without conditional written_bytes_long += m_longsuperblock[i].serialize(out); - } else { + } else { // TODO possible without conditional written_bytes_mini += m_miniblock[i].serialize(out); } written_bytes += written_bytes_long; @@ -495,7 +495,7 @@ void select_support_mcl::load(std::istream& in, const bit_vector* m_longsuperblock = new int_vector<0>[sb]; // Create longsuperblock int_vector<0> for (size_type i=0; i < sb; ++i) - if (!mini_or_long.empty() and not mini_or_long[i]) { + if (!mini_or_long.empty() and not mini_or_long[i]) { // TODO possible without conditional m_longsuperblock[i].load(in); } else { m_miniblock[i].load(in); diff --git a/include/sdsl/suffix_array_algorithm.hpp b/include/sdsl/suffix_array_algorithm.hpp index 8c066483f..e392070ec 100644 --- a/include/sdsl/suffix_array_algorithm.hpp +++ b/include/sdsl/suffix_array_algorithm.hpp @@ -478,7 +478,7 @@ typename t_csa::size_type extract( typename t_csa::size_type steps = end-begin+1; for (typename t_csa::size_type i=0, order = csa.isa[begin]; steps != 0; --steps, ++i) { text[i] = first_row_symbol(order, csa); - if (steps != 0) order = csa.psi[order]; + if (steps != 0) order = csa.psi[order]; // TODO possible without conditional } return end-begin+1; } diff --git a/include/sdsl/suffix_tree_algorithm.hpp b/include/sdsl/suffix_tree_algorithm.hpp index 7ca5d428e..7ef0b8013 100644 --- a/include/sdsl/suffix_tree_algorithm.hpp +++ b/include/sdsl/suffix_tree_algorithm.hpp @@ -255,8 +255,8 @@ std::pair Hk(const t_cst& cst, typename t_cst::size_type k) if (it.visit() == 1) { if (!cst.is_leaf(*it)) { typename t_cst::size_type d = cst.depth(*it); - if (d >= k) { - if (d == k) { + if (d >= k) { // TODO possible without conditional + if (d == k) { // TODO possible without conditional hk += cst.size(*it) * H0(*it, cst); } ++context; diff --git a/include/sdsl/suffix_tree_helper.hpp b/include/sdsl/suffix_tree_helper.hpp index 8850052e9..2384f1766 100644 --- a/include/sdsl/suffix_tree_helper.hpp +++ b/include/sdsl/suffix_tree_helper.hpp @@ -91,12 +91,12 @@ void construct_supercartesian_tree_bp(const t_rac& vec, bit_vector& bp, const bo size_type k=0; for (size_type i=0; i < vec.size(); ++i) { typename t_rac::value_type l = vec[i]; - if (minimum) { + if (minimum) { // TODO possible without conditional (use lambdas) while (vec_stack.size() > 0 and l < vec_stack.top()) { vec_stack.pop(); ++k; /*bp[k++] = 0; bp is already initialized to zero*/ // writing a closing parenthesis } - } else { + } else { // TODO possible without conditional (use lambdas) while (vec_stack.size() > 0 and l > vec_stack.top()) { vec_stack.pop(); ++k; /*bp[k++] = 0; bp is already initialized to zero*/ // writing a closing parenthesis } diff --git a/include/sdsl/vlc_vector.hpp b/include/sdsl/vlc_vector.hpp index ef20e2e77..b56a06d6c 100644 --- a/include/sdsl/vlc_vector.hpp +++ b/include/sdsl/vlc_vector.hpp @@ -190,7 +190,7 @@ vlc_vector::vlc_vector(const Container& c) size_type samples = 0, z_size = 0; // (1) Calculate size of z for (size_type i=0; i < c.size(); ++i) { - if (c[i]+1<1) { + if (c[i]+1<1) { // TODO make sure this happens only in DEBUG mode throw std::logic_error("vlc_vector cannot decode values smaller than 1!"); } z_size += t_coder::encoding_length(c[i]+1); @@ -205,7 +205,7 @@ vlc_vector::vlc_vector(const Container& c) uint8_t offset = 0; size_type no_sample = 0; for (size_type i=0, sample_cnt=0; i < c.size(); ++i, --no_sample) { - if (!no_sample) { // add a sample pointer + if (!no_sample) { // add a sample pointer // TODO This branch can be avoided no_sample = get_sample_dens(); m_sample_pointer[sample_cnt++] = z_size; } @@ -227,7 +227,7 @@ vlc_vector::vlc_vector(int_vector_buffer& v // (1) Calculate size of z for (size_type i=0; i < n; ++i) { size_type x = v_buf[i]+1; - if (x < 1) { + if (x < 1) { // TODO make sure this happens only in DEBUG mode throw std::logic_error("vlc_vector cannot decode values smaller than 1!"); } z_size += t_coder::encoding_length(x); @@ -246,7 +246,7 @@ vlc_vector::vlc_vector(int_vector_buffer& v // (c) Write sample values and deltas size_type no_sample = 0; for (size_type i=0, sample_cnt = 0; i < n; ++i, --no_sample) { - if (!no_sample) { // add a sample pointer + if (!no_sample) { // add a sample pointer // TODO this branch can be avoided no_sample = get_sample_dens(); m_sample_pointer[sample_cnt++] = z_size; } diff --git a/include/sdsl/wm_int.hpp b/include/sdsl/wm_int.hpp index 7dfc816c7..23611e73c 100644 --- a/include/sdsl/wm_int.hpp +++ b/include/sdsl/wm_int.hpp @@ -160,7 +160,7 @@ class wm_int value_type x = 1; // variable for the biggest value in rac for (size_type i=0; i < m_size; ++i) { // detect the largest value in rac - if (buf[i] > x) + if (buf[i] > x) // TODO why not to use std::max here? x = buf[i]; rac[i] = buf[i]; } @@ -308,10 +308,10 @@ class wm_int for (uint32_t k=0; k < m_max_level; ++k) { res <<= 1; size_type rank_ones = m_tree_rank(i) - m_rank_level[k]; - if (m_tree[i]) { // one at position i => follow right child + if (m_tree[i]) { // one at position i => follow right child // TODO can be done without branch i = (k+1)*m_size + m_zero_cnt[k] + rank_ones; res |= 1; - } else { // zero at position i => follow left child + } else { // zero at position i => follow left child // TODO can be done without branch auto rank_zeros = (i - k*m_size) - rank_ones; i = (k+1)*m_size + rank_zeros; } @@ -340,10 +340,10 @@ class wm_int size_type rank_b = m_tree_rank(b); size_type ones = m_tree_rank(b + i) - rank_b; // ones in [b..i) size_type ones_p = rank_b - m_rank_level[k]; // ones in [level_b..b) - if (c & mask) { // search for a one at this level + if (c & mask) { // search for a one at this level // TODO can be done without branch i = ones; b = (k+1)*m_size + m_zero_cnt[k] + ones_p; - } else { // search for a zero at this level + } else { // search for a zero at this level // TODO can be done without branch i = i-ones; b = (k+1)*m_size + (b - k*m_size - ones_p); } @@ -370,11 +370,11 @@ class wm_int size_type ones = m_tree_rank(b + i) - rank_b; // ones in [b..i) size_type ones_p = rank_b - m_rank_level[k]; // ones in [level_b..b) c<<=1; - if (m_tree[b+i]) { // go to the right child + if (m_tree[b+i]) { // go to the right child // TODO can be done without branch i = ones; b = (k+1)*m_size + m_zero_cnt[k] + ones_p; c|=1; - } else { // go to the left child + } else { // go to the left child // TODO can be done without branch i = i-ones; b = (k+1)*m_size + (b - k*m_size - ones_p); } @@ -402,10 +402,10 @@ class wm_int size_type rank_b = m_tree_rank(b); size_type ones = m_tree_rank(b + r) - rank_b; // ones in [b..i) size_type ones_p = rank_b - m_rank_level[k]; // ones in [0..b) - if (c & mask) { // search for a one at this level + if (c & mask) { // search for a one at this level // TODO can be done without branch r = ones; b = (k+1)*m_size + m_zero_cnt[k] + ones_p; - } else { // search for a zero at this level + } else { // search for a zero at this level // TODO can be done without branch r = r-ones; b = (k+1)*m_size + (b - k*m_size - ones_p); } @@ -417,9 +417,9 @@ class wm_int for (uint32_t k=m_max_level; k>0; --k) { b = m_path_off[k-1]; size_type rank_b = m_path_rank_off[k-1]; - if (c & mask) { // right child => search i'th one + if (c & mask) { // right child => search i'th one // TODO can be done without branch i = m_tree_select1(rank_b + i) - b + 1; - } else { // left child => search i'th zero + } else { // left child => search i'th zero // TODO can be done without branch i = m_tree_select0(b - rank_b + i) - b + 1; } mask <<= 1; @@ -473,9 +473,9 @@ class wm_int for (uint32_t k=m_max_level; k>0; --k) { size_type offset = is[k-1]; size_type rank_offset = rank_off[k-1]; - if (c&1) { + if (c&1) { // TODO can be done without branch i = m_tree_select1(rank_offset+i)-offset+1; - } else { + } else { // TODO can be done without branch i = m_tree_select0(offset-rank_offset+i)-offset+1; } c >>= 1; diff --git a/include/sdsl/wt_gmr.hpp b/include/sdsl/wt_gmr.hpp index c2bdbb989..0c433ba0d 100644 --- a/include/sdsl/wt_gmr.hpp +++ b/include/sdsl/wt_gmr.hpp @@ -92,14 +92,14 @@ class inv_multi_perm_support j = j_new; done[j-off] = 1; ++steps; ++all_steps; - if (t_s == steps) { + if (t_s == steps) { // TODO can be done without branch max_back_pointer = std::max(max_back_pointer, back_pointer-off); marked[j] = 1; steps = 0; back_pointer = j; } } - if (all_steps > t_s) { + if (all_steps > t_s) { // TODO can be done without branch marked[i] = 1; max_back_pointer = std::max(max_back_pointer, back_pointer-off); } @@ -126,13 +126,13 @@ class inv_multi_perm_support j = j_new; done[j-off] = 1; ++steps; ++all_steps; - if (t_s == steps) { + if (t_s == steps) { // TODO can be done without branch m_back_pointer[m_marked_rank(j)] = back_pointer-off; steps = 0; back_pointer = j; } } - if (all_steps > t_s) { + if (all_steps > t_s) { // TODO can be done without branch m_back_pointer[m_marked_rank(i)] = back_pointer-off; } } @@ -328,7 +328,7 @@ class wt_gmr_rs wt_gmr_rs(int_vector_buffer& input, size_type size) : m_size(size) { // Determine max. symbol for (uint64_t i=0; i tmp(m_block_size*m_blocks, 0, bits::hi(m_block_size)+1); for (uint64_t i=0, offset=0, j=0; i& input, size_type size) : m_size(size) { // Determine max. symbol for (uint64_t i=0; i tmp(m_max_symbol*m_chunks, 0, bits::hi(m_max_symbol-1)+2); for (uint64_t i=0, offset=0, j=0; i 56) { + if (pl > 56) { // TODO ensure this happens only in DEBUG mode throw std::logic_error("Code depth greater than 56!!!"); } m_path[c] = pw | (pl << 56); @@ -235,7 +235,7 @@ struct _byte_tree { template void init_node_ranks(const t_rank_type& rank) { for (uint64_t i=0; i max_c) max_c = c; + if (c > max_c) max_c = c; // TODO branch can be avoided } } m_path = std::vector(m_c_to_leaf.size(), 0); @@ -457,12 +457,12 @@ struct _int_tree { uint64_t l = 0; // path len while (v != root()) { // while node is not the root w <<= 1; - if (m_nodes[m_nodes[v].parent].child[1] == v) // if the node is a right child + if (m_nodes[m_nodes[v].parent].child[1] == v) // if the node is a right child // TODO branch can be avoided w |= 1ULL; ++l; v = m_nodes[v].parent; // go up the tree } - if (l > 56) { + if (l > 56) { // TODO ensure this happens only in DEBUG mode throw std::logic_error("Code depth greater than 56!!!"); } m_path[c] = w | (l << 56); @@ -477,7 +477,7 @@ struct _int_tree { template void init_node_ranks(const t_rank_type& rank) { for (uint64_t i=0; i node_vector; for (size_t i = 0; i < C.size(); i++) { - if (C[i]) { + if (C[i]) { // TODO branch can be avoided ht_node n; n.c = (uint64_t)i; n.w = C[i]; diff --git a/include/sdsl/wt_int.hpp b/include/sdsl/wt_int.hpp index 1d7b4ca66..77610307b 100644 --- a/include/sdsl/wt_int.hpp +++ b/include/sdsl/wt_int.hpp @@ -192,7 +192,7 @@ class wt_int value_type x = 1; // variable for the biggest value in rac for (size_type i=0; i < m_size; ++i) { - if (buf[i] > x) + if (buf[i] > x) // TODO branch can be avoided x = buf[i]; rac[i] = buf[i]; } @@ -228,24 +228,24 @@ class wt_int uint64_t start_value = (rac[i]&mask_old); uint64_t x; while (i < m_size and((x=rac[i])&mask_old)==start_value) { - if (x&mask_new) { + if (x&mask_new) { // TODO branch can be avoided tree_word |= (1ULL << (tree_pos&0x3FULL)); buf1[cnt1++] = x; - } else { + } else { // TODO branch can be avoided rac[start + cnt0++ ] = x; } ++tree_pos; - if ((tree_pos & 0x3FULL) == 0) { // if tree_pos % 64 == 0 write old word + if ((tree_pos & 0x3FULL) == 0) { // if tree_pos % 64 == 0 write old word // TODO branch can be avoided tree_out_buf.write((char*) &tree_word, sizeof(tree_word)); tree_word = 0; } ++i; } - if (k+1 < m_max_level) { // inner node - for (size_type j=0; j0) + (cnt1>0); // increase sigma for each leaf } start += cnt0+cnt1; @@ -345,12 +345,12 @@ class wt_int size_type ones_before_o = m_tree_rank(offset); size_type ones_before_i = m_tree_rank(offset + i) - ones_before_o; size_type ones_before_end = m_tree_rank(offset + node_size) - ones_before_o; - if (m_tree[offset+i]) { // one at position i => follow right child + if (m_tree[offset+i]) { // one at position i => follow right child // TODO branch can be avoided offset += (node_size - ones_before_end); node_size = ones_before_end; i = ones_before_i; res |= 1; - } else { // zero at position i => follow left child + } else { // zero at position i => follow left child // TODO branch can be avoided node_size = (node_size - ones_before_end); i = (i-ones_before_i); } @@ -381,11 +381,11 @@ class wt_int size_type ones_before_o = m_tree_rank(offset); size_type ones_before_i = m_tree_rank(offset + i) - ones_before_o; size_type ones_before_end = m_tree_rank(offset + node_size) - ones_before_o; - if (c & mask) { // search for a one at this level + if (c & mask) { // search for a one at this level // TODO branch can be avoided offset += (node_size - ones_before_end); node_size = ones_before_end; i = ones_before_i; - } else { // search for a zero at this level + } else { // search for a zero at this level // TODO branch can be avoided node_size = (node_size - ones_before_end); i = (i-ones_before_i); } @@ -415,12 +415,12 @@ class wt_int size_type ones_before_i = m_tree_rank(offset + i) - ones_before_o; size_type ones_before_end = m_tree_rank(offset + node_size) - ones_before_o; c<<=1; - if (m_tree[offset+i]) { // go to the right child + if (m_tree[offset+i]) { // go to the right child // TODO branch can be avoided offset += (node_size - ones_before_end); node_size = ones_before_end; i = ones_before_i; c|=1; - } else { // go to the left child + } else { // go to the left child // TODO branch can be avoided node_size = (node_size - ones_before_end); i = (i-ones_before_i); } @@ -450,10 +450,10 @@ class wt_int size_type ones_before_o = m_tree_rank(offset); m_path_rank_off[k] = ones_before_o; size_type ones_before_end = m_tree_rank(offset + node_size) - ones_before_o; - if (c & mask) { // search for a one at this level + if (c & mask) { // search for a one at this level // TODO branch can be avoided offset += (node_size - ones_before_end); node_size = ones_before_end; - } else { // search for a zero at this level + } else { // search for a zero at this level // TODO branch can be avoided node_size = (node_size - ones_before_end); } offset += m_size; @@ -468,9 +468,9 @@ class wt_int for (uint32_t k=m_max_level; k>0; --k) { offset = m_path_off[k-1]; size_type ones_before_o = m_path_rank_off[k-1]; - if (c & mask) { // right child => search i'th + if (c & mask) { // right child => search i'th // TODO branch can be avoided i = m_tree_select1(ones_before_o + i) - offset + 1; - } else { // left child => search i'th zero + } else { // left child => search i'th zero // TODO branch can be avoided i = m_tree_select0(offset - ones_before_o + i) - offset + 1; } mask <<= 1; @@ -551,13 +551,13 @@ class wt_int size_type ones_before_i = m_tree_rank(offset + i) - ones_before_o; size_type ones_before_j = m_tree_rank(offset + j) - ones_before_o; size_type ones_before_end = m_tree_rank(offset + node_size) - ones_before_o; - if (c & mask) { // search for a one at this level + if (c & mask) { // search for a one at this level // TODO branch can be avoided offset += (node_size - ones_before_end); node_size = ones_before_end; smaller += j-i-ones_before_j+ones_before_i; i = ones_before_i; j = ones_before_j; - } else { // search for a zero at this level + } else { // search for a zero at this level // TODO branch can be avoided node_size -= ones_before_end; greater += ones_before_j-ones_before_i; i -= ones_before_i; @@ -593,12 +593,12 @@ class wt_int size_type ones_before_o = m_tree_rank(offset); size_type ones_before_i = m_tree_rank(offset + i) - ones_before_o; size_type ones_before_end = m_tree_rank(offset + node_size) - ones_before_o; - if (c & mask) { // search for a one at this level + if (c & mask) { // search for a one at this level // TODO branch can be avoided offset += (node_size - ones_before_end); node_size = ones_before_end; result += i - ones_before_i; i = ones_before_i; - } else { // search for a zero at this level + } else { // search for a zero at this level // TODO branch can be avoided node_size = (node_size - ones_before_end); i -= ones_before_i; } diff --git a/include/sdsl/wt_pc.hpp b/include/sdsl/wt_pc.hpp index edfb46f13..de5cdde10 100644 --- a/include/sdsl/wt_pc.hpp +++ b/include/sdsl/wt_pc.hpp @@ -216,7 +216,7 @@ class wt_pc for (size_type v=0; v < m_tree.size(); ++v) { bv_node_pos[v] = m_tree.bv_pos(v); } - if (input_buf.size() < size) { + if (input_buf.size() < size) { // TODO ensure this happens in DEBUG mode only throw std::logic_error("Stream size is smaller than size!"); return; } @@ -359,10 +359,10 @@ class wt_pc size_type result = i; node_type v = m_tree.root(); for (uint32_t l=0; l>= 1) { - if (p&1) { + if (p&1) { // TODO branch can be avoided result = (m_bv_rank(m_tree.bv_pos(v)+result) - m_tree.bv_pos_rank(v)); - } else { + } else { // TODO branch can be avoided result -= (m_bv_rank(m_tree.bv_pos(v)+result) - m_tree.bv_pos_rank(v)); } @@ -426,12 +426,12 @@ class wt_pc // path_len > 0, since we have handled m_sigma = 1. p <<= (64-path_len); for (uint32_t l=0; l>= 1) { size_type ones = (m_bv_rank(m_tree.bv_pos(v)+all) - m_tree.bv_pos_rank(v)); - if (p&1) { + if (p&1) { // TODO branch can be avoided result += all - ones; all = ones; - } else { + } else { // TODO branch can be avoided all -= ones; } v = m_tree.child(v, p&1); diff --git a/include/sdsl/wt_rlmn.hpp b/include/sdsl/wt_rlmn.hpp index d28d0d118..d31766ae8 100644 --- a/include/sdsl/wt_rlmn.hpp +++ b/include/sdsl/wt_rlmn.hpp @@ -208,7 +208,7 @@ class wt_rlmn bf[size] = 1; // initialize last element for (size_type i=0; i < size; ++i) { value_type c = text_buf[i]; - if (bl[i]) { + if (bl[i]) { // TODO branch can be avoided bf[lf_map[c]] = 1; } ++lf_map[c];