diff --git a/fi/include/frequent_items_sketch_impl.hpp b/fi/include/frequent_items_sketch_impl.hpp index acbd2ee1..3eba188b 100644 --- a/fi/include/frequent_items_sketch_impl.hpp +++ b/fi/include/frequent_items_sketch_impl.hpp @@ -45,13 +45,13 @@ map( allocator ) { - if (lg_start_map_size > lg_max_map_size) throw std::invalid_argument("starting size must not be greater than maximum size"); + if (lg_start_map_size > lg_max_map_size) { throw std::invalid_argument("starting size must not be greater than maximum size"); } } template void frequent_items_sketch::update(const T& item, W weight) { check_weight(weight); - if (weight == 0) return; + if (weight == 0) { return; } total_weight += weight; offset += map.adjust_or_insert(item, weight); } @@ -59,14 +59,14 @@ void frequent_items_sketch::update(const T& item, W weight) { template void frequent_items_sketch::update(T&& item, W weight) { check_weight(weight); - if (weight == 0) return; + if (weight == 0) { return; } total_weight += weight; offset += map.adjust_or_insert(std::move(item), weight); } template void frequent_items_sketch::merge(const frequent_items_sketch& other) { - if (other.is_empty()) return; + if (other.is_empty()) { return; } const W merged_total_weight = total_weight + other.get_total_weight(); // for correction at the end for (auto it: other.map) { update(it.first, it.second); @@ -77,7 +77,7 @@ void frequent_items_sketch::merge(const frequent_items_sketch& ot template void frequent_items_sketch::merge(frequent_items_sketch&& other) { - if (other.is_empty()) return; + if (other.is_empty()) { return; } const W merged_total_weight = total_weight + other.get_total_weight(); // for correction at the end for (auto it: other.map) { update(std::move(it.first), it.second); @@ -105,7 +105,7 @@ template W frequent_items_sketch::get_estimate(const T& item) const { // if item is tracked estimate = weight + offset, otherwise 0 const W weight = map.get(item); - if (weight > 0) return weight + offset; + if (weight > 0) { return weight + offset; } return 0; } @@ -210,7 +210,7 @@ void frequent_items_sketch::serialize(std::ostream& os, const Ser template template size_t frequent_items_sketch::get_serialized_size_bytes(const SerDe& sd) const { - if (is_empty()) return PREAMBLE_LONGS_EMPTY * sizeof(uint64_t); + if (is_empty()) { return PREAMBLE_LONGS_EMPTY * sizeof(uint64_t); } size_t size = PREAMBLE_LONGS_NONEMPTY * sizeof(uint64_t) + map.get_num_active() * sizeof(W); for (auto it: map) size += sd.size_of_item(it.first); return size; @@ -328,8 +328,7 @@ frequent_items_sketch frequent_items_sketch::deser sketch.total_weight = total_weight; sketch.offset = offset; } - if (!is.good()) - throw std::runtime_error("error reading from std::istream"); + if (!is.good()) { throw std::runtime_error("error reading from std::istream"); } return sketch; } diff --git a/fi/include/reverse_purge_hash_map_impl.hpp b/fi/include/reverse_purge_hash_map_impl.hpp index fa2ad824..63909cf3 100644 --- a/fi/include/reverse_purge_hash_map_impl.hpp +++ b/fi/include/reverse_purge_hash_map_impl.hpp @@ -74,7 +74,7 @@ states_(nullptr) if (other.states_[i] > 0) { new (&keys_[i]) K(other.keys_[i]); values_[i] = other.values_[i]; - if (--num == 0) break; + if (--num == 0) { break; } } } } @@ -105,7 +105,7 @@ reverse_purge_hash_map::~reverse_purge_hash_map() { for (uint32_t i = 0; i < size; i++) { if (is_active(i)) { keys_[i].~K(); - if (--num_active_ == 0) break; + if (--num_active_ == 0) { break; } } } } @@ -166,7 +166,7 @@ V reverse_purge_hash_map::get(const K& key) const { const uint32_t mask = (1 << lg_cur_size_) - 1; uint32_t probe = fmix64(H()(key)) & mask; while (is_active(probe)) { - if (E()(keys_[probe], key)) return values_[probe]; + if (E()(keys_[probe], key)) { return values_[probe]; } probe = (probe + 1) & mask; } return 0; @@ -271,7 +271,7 @@ void reverse_purge_hash_map::hash_delete(uint32_t delete_index) { probe = (probe + 1) & mask; drift++; // only used for theoretical analysis - if (drift >= DRIFT_LIMIT) throw std::logic_error("drift: " + std::to_string(drift) + " >= DRIFT_LIMIT"); + if (drift >= DRIFT_LIMIT) { throw std::logic_error("drift: " + std::to_string(drift) + " >= DRIFT_LIMIT"); } } } @@ -289,7 +289,7 @@ uint32_t reverse_purge_hash_map::internal_adjust_or_insert(const index = (index + 1) & mask; drift++; // only used for theoretical analysis - if (drift >= DRIFT_LIMIT) throw std::logic_error("drift limit reached"); + if (drift >= DRIFT_LIMIT) { throw std::logic_error("drift limit reached"); } } // adding the key and value to the table if (num_active_ > get_capacity()) {