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

Various noexcept specifiers in IOBuf

Summary: [Folly] Various `noexcept` specifiers in `IOBuf`.

Reviewed By: Orvid

Differential Revision: D10081705

fbshipit-source-id: 5516e7deca4edd50ea99e61e10cd413f3c0f17ae
parent aaf9e970
......@@ -335,7 +335,7 @@ unique_ptr<IOBuf> IOBuf::takeOwnership(
}
}
IOBuf::IOBuf(WrapBufferOp, const void* buf, std::size_t capacity)
IOBuf::IOBuf(WrapBufferOp, const void* buf, std::size_t capacity) noexcept
: IOBuf(
InternalConstructor(),
0,
......@@ -347,13 +347,14 @@ IOBuf::IOBuf(WrapBufferOp, const void* buf, std::size_t capacity)
static_cast<uint8_t*>(const_cast<void*>(buf)),
capacity) {}
IOBuf::IOBuf(WrapBufferOp op, ByteRange br) : IOBuf(op, br.data(), br.size()) {}
IOBuf::IOBuf(WrapBufferOp op, ByteRange br) noexcept
: IOBuf(op, br.data(), br.size()) {}
unique_ptr<IOBuf> IOBuf::wrapBuffer(const void* buf, std::size_t capacity) {
return std::make_unique<IOBuf>(WRAP_BUFFER, buf, capacity);
}
IOBuf IOBuf::wrapBufferAsValue(const void* buf, std::size_t capacity) {
IOBuf IOBuf::wrapBufferAsValue(const void* buf, std::size_t capacity) noexcept {
return IOBuf(WrapBufferOp::WRAP_BUFFER, buf, capacity);
}
......@@ -399,7 +400,7 @@ IOBuf::IOBuf(
uint8_t* buf,
std::size_t capacity,
uint8_t* data,
std::size_t length)
std::size_t length) noexcept
: next_(this),
prev_(this),
data_(data),
......@@ -1048,7 +1049,7 @@ size_t IOBuf::fillIov(struct iovec* iov, size_t len) const {
return 0;
}
size_t IOBufHash::operator()(const IOBuf& buf) const {
size_t IOBufHash::operator()(const IOBuf& buf) const noexcept {
folly::hash::SpookyHashV2 hasher;
hasher.Init(0, 0);
io::Cursor cursor(&buf);
......@@ -1066,7 +1067,7 @@ size_t IOBufHash::operator()(const IOBuf& buf) const {
return static_cast<std::size_t>(h1);
}
ordering IOBufCompare::impl(const IOBuf& a, const IOBuf& b) const {
ordering IOBufCompare::impl(const IOBuf& a, const IOBuf& b) const noexcept {
io::Cursor ca(&a);
io::Cursor cb(&b);
for (;;) {
......@@ -1081,6 +1082,7 @@ ordering IOBufCompare::impl(const IOBuf& a, const IOBuf& b) const {
if (r != ordering::eq) {
return r;
}
// Cursor::skip() may throw if n is too large, but n is not too large here
ca.skip(n);
cb.skip(n);
}
......
......@@ -392,13 +392,15 @@ class IOBuf {
* Similar to wrapBuffer(), but returns IOBuf by value rather than
* heap-allocating it.
*/
static IOBuf wrapBufferAsValue(const void* buf, std::size_t capacity);
static IOBuf wrapBufferAsValue(ByteRange br) {
static IOBuf wrapBufferAsValue(
const void* buf,
std::size_t capacity) noexcept;
static IOBuf wrapBufferAsValue(ByteRange br) noexcept {
return wrapBufferAsValue(br.data(), br.size());
}
IOBuf(WrapBufferOp op, const void* buf, std::size_t capacity);
IOBuf(WrapBufferOp op, ByteRange br);
IOBuf(WrapBufferOp op, const void* buf, std::size_t capacity) noexcept;
IOBuf(WrapBufferOp op, ByteRange br) noexcept;
/**
* Convenience function to create a new IOBuf object that copies data from a
......@@ -1329,7 +1331,7 @@ class IOBuf {
uint8_t* buf,
std::size_t capacity,
uint8_t* data,
std::size_t length);
std::size_t length) noexcept;
void unshareOneSlow();
void unshareChained();
......@@ -1463,8 +1465,8 @@ class IOBuf {
* Hasher for IOBuf objects. Hashes the entire chain using SpookyHashV2.
*/
struct IOBufHash {
size_t operator()(const IOBuf& buf) const;
size_t operator()(const std::unique_ptr<IOBuf>& buf) const {
size_t operator()(const IOBuf& buf) const noexcept;
size_t operator()(const std::unique_ptr<IOBuf>& buf) const noexcept {
return buf ? (*this)(*buf) : 0;
}
};
......@@ -1489,7 +1491,7 @@ struct IOBufCompare {
}
private:
ordering impl(IOBuf const& a, IOBuf const& b) const;
ordering impl(IOBuf const& a, IOBuf const& b) const noexcept;
};
/**
......
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