folly::StringPiece getRange(const folly::IOBuf& buf) { assert(!buf.isChained()); return {reinterpret_cast<const char*>(buf.data()), buf.length()}; }
bool hasSameMemoryRegion(const folly::IOBuf& buf, folly::StringPiece range) { return !buf.isChained() && (buf.length() == 0 || (range.begin() == reinterpret_cast<const char*>(buf.data()) && range.size() == buf.length())); }
bool hasSameMemoryRegion(const folly::IOBuf& a, const folly::IOBuf& b) { return !a.isChained() && !b.isChained() && ((a.length() == 0 && b.length() == 0) || (a.data() == b.data() && a.length() == b.length())); }