summaryrefslogtreecommitdiff
path: root/absl/container/internal
diff options
context:
space:
mode:
authorGravatar Evan Brown <ezb@google.com>2022-10-18 11:45:09 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-10-18 11:45:57 -0700
commit24c32c7de239a2d4c81f67d7eb241c0c4aa38a63 (patch)
tree65106acc7f2437fdd947e60b37fb199f6da1f3d0 /absl/container/internal
parent4bc7568c70822dae40eea3f27a3051a618021651 (diff)
Use btree iterator subtraction instead of std::distance in erase_range() and count().
PiperOrigin-RevId: 481979737 Change-Id: I69f53665b0463a7d8d80f2a3feedfdd95d32b012
Diffstat (limited to 'absl/container/internal')
-rw-r--r--absl/container/internal/btree.h2
-rw-r--r--absl/container/internal/btree_container.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/absl/container/internal/btree.h b/absl/container/internal/btree.h
index 9c509073..5000d1c3 100644
--- a/absl/container/internal/btree.h
+++ b/absl/container/internal/btree.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) {
diff --git a/absl/container/internal/btree_container.h b/absl/container/internal/btree_container.h
index fc2f740a..3e259861 100644
--- a/absl/container/internal/btree_container.h
+++ b/absl/container/internal/btree_container.h
@@ -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) {