Commit aa554761 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Let IOBufCompare have a self-compare shortcut

Summary: [Folly] Let `IOBufCompare` have a self-compare shortcut.

Reviewed By: vitaut

Differential Revision: D9981523

fbshipit-source-id: e984cffc2816a0f4f06bf418b16d4d3eb055f6ef
parent 271f9740
......@@ -1066,7 +1066,7 @@ size_t IOBufHash::operator()(const IOBuf& buf) const {
return static_cast<std::size_t>(h1);
}
ordering IOBufCompare::operator()(const IOBuf& a, const IOBuf& b) const {
ordering IOBufCompare::impl(const IOBuf& a, const IOBuf& b) const {
io::Cursor ca(&a);
io::Cursor cb(&b);
for (;;) {
......
......@@ -1473,7 +1473,9 @@ struct IOBufHash {
* Ordering for IOBuf objects. Compares data in the entire chain.
*/
struct IOBufCompare {
ordering operator()(const IOBuf& a, const IOBuf& b) const;
ordering operator()(const IOBuf& a, const IOBuf& b) const {
return &a == &b ? ordering::eq : impl(a, b);
}
ordering operator()(
const std::unique_ptr<IOBuf>& a,
const std::unique_ptr<IOBuf>& b) const {
......@@ -1485,6 +1487,9 @@ struct IOBufCompare {
operator()(*a, *b);
// clang-format on
}
private:
ordering impl(IOBuf const& a, IOBuf const& b) const;
};
/**
......
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