Use btree iterator subtraction instead of std::distance in erase_range() and count().

PiperOrigin-RevId: 481979737
Change-Id: I69f53665b0463a7d8d80f2a3feedfdd95d32b012
pull/1115/head
Evan Brown 2 years ago committed by Copybara-Service
parent 4bc7568c70
commit 24c32c7de2
  1. 2
      absl/container/internal/btree.h
  2. 2
      absl/container/internal/btree_container.h

@ -2444,7 +2444,7 @@ auto btree<P>::rebalance_after_delete(iterator iter) -> iterator {
template <typename P>
auto btree<P>::erase_range(iterator begin, iterator end)
-> std::pair<size_type, iterator> {
size_type count = static_cast<size_type>(std::distance(begin, end));
size_type count = static_cast<size_type>(end - begin);
assert(count >= 0);
if (count == 0) {

@ -107,7 +107,7 @@ class btree_container {
template <typename K = key_type>
size_type count(const key_arg<K> &key) const {
auto equal_range = this->equal_range(key);
return std::distance(equal_range.first, equal_range.second);
return equal_range.second - equal_range.first;
}
template <typename K = key_type>
iterator find(const key_arg<K> &key) {

Loading…
Cancel
Save