Commit 594f18f7 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot 5

Inline the lower_bound and upper_bound callbacks in sorted_vector_map

Summary:
[Folly] Inline the `lower_bound` and `upper_bound` callbacks in `sorted_vector_map`.

Avoids unnecessary use of legacy `boost::bind`, and allows the compiler to avoid the indirection it introduces. This way, we use templates instead of vtables.

Reviewed By: Orvid

Differential Revision: D3545939

fbshipit-source-id: 277e9e4862beb71e99b94a62308783771071d2bc
parent c8f4d603
...@@ -572,23 +572,27 @@ public: ...@@ -572,23 +572,27 @@ public:
} }
iterator lower_bound(const key_type& key) { iterator lower_bound(const key_type& key) {
return std::lower_bound(begin(), end(), key, auto c = key_comp();
boost::bind(key_comp(), boost::bind(&value_type::first, _1), _2)); auto f = [&](const auto& a, const auto& b) { return c(a.first, b); };
return std::lower_bound(begin(), end(), key, f);
} }
const_iterator lower_bound(const key_type& key) const { const_iterator lower_bound(const key_type& key) const {
return std::lower_bound(begin(), end(), key, auto c = key_comp();
boost::bind(key_comp(), boost::bind(&value_type::first, _1), _2)); auto f = [&](const auto& a, const auto& b) { return c(a.first, b); };
return std::lower_bound(begin(), end(), key, f);
} }
iterator upper_bound(const key_type& key) { iterator upper_bound(const key_type& key) {
return std::upper_bound(begin(), end(), key, auto c = key_comp();
boost::bind(key_comp(), _1, boost::bind(&value_type::first, _2))); auto f = [&](const auto& a, const auto& b) { return c(a, b.first); };
return std::upper_bound(begin(), end(), key, f);
} }
const_iterator upper_bound(const key_type& key) const { const_iterator upper_bound(const key_type& key) const {
return std::upper_bound(begin(), end(), key, auto c = key_comp();
boost::bind(key_comp(), _1, boost::bind(&value_type::first, _2))); auto f = [&](const auto& a, const auto& b) { return c(a, b.first); };
return std::upper_bound(begin(), end(), key, f);
} }
std::pair<iterator,iterator> equal_range(const key_type& key) { std::pair<iterator,iterator> equal_range(const key_type& key) {
...@@ -596,8 +600,9 @@ public: ...@@ -596,8 +600,9 @@ public:
// argument types different from the iterator value_type, so we // argument types different from the iterator value_type, so we
// have to do this. // have to do this.
iterator low = lower_bound(key); iterator low = lower_bound(key);
iterator high = std::upper_bound(low, end(), key, auto c = key_comp();
boost::bind(key_comp(), _1, boost::bind(&value_type::first, _2))); auto f = [&](const auto& a, const auto& b) { return c(a, b.first); };
iterator high = std::upper_bound(low, end(), key, f);
return std::make_pair(low, high); return std::make_pair(low, high);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment