[algs] Implement swap() for pair_t
Helps priority_queue::pop_minimum and friends, which help subsetter repacker. Shows a few percentage improvement on NotoNastaliq benchmark.
This commit is contained in:
parent
a2984a2932
commit
35878df215
|
@ -484,6 +484,17 @@ struct
|
|||
}
|
||||
HB_FUNCOBJ (hb_equal);
|
||||
|
||||
struct
|
||||
{
|
||||
template <typename T> void
|
||||
operator () (T& a, T& b) const
|
||||
{
|
||||
using std::swap; // allow ADL
|
||||
swap (a, b);
|
||||
}
|
||||
}
|
||||
HB_FUNCOBJ (hb_swap);
|
||||
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct hb_pair_t
|
||||
|
@ -513,6 +524,13 @@ struct hb_pair_t
|
|||
bool operator > (const pair_t& o) const { return first > o.first || (first == o.first && second > o.second); }
|
||||
bool operator <= (const pair_t& o) const { return !(*this > o); }
|
||||
|
||||
friend void swap (hb_pair_t& a, hb_pair_t& b)
|
||||
{
|
||||
hb_swap (a.first, b.first);
|
||||
hb_swap (a.second, b.second);
|
||||
}
|
||||
|
||||
|
||||
T1 first;
|
||||
T2 second;
|
||||
};
|
||||
|
@ -559,17 +577,6 @@ struct
|
|||
}
|
||||
HB_FUNCOBJ (hb_clamp);
|
||||
|
||||
struct
|
||||
{
|
||||
template <typename T> void
|
||||
operator () (T& a, T& b) const
|
||||
{
|
||||
using std::swap; // allow ADL
|
||||
swap (a, b);
|
||||
}
|
||||
}
|
||||
HB_FUNCOBJ (hb_swap);
|
||||
|
||||
/*
|
||||
* Bithacks.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue