Skip to content

Commit

Permalink
mark IOBufQueue move-assignment as noexcept
Browse files Browse the repository at this point in the history
Summary: And so mark its callees and various other similar functions.

Reviewed By: ot

Differential Revision: D64242335

fbshipit-source-id: bc85341a41fda5dd3d6026df7c87d2f183ae59ff
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Oct 11, 2024
1 parent 9de7eae commit 8c449c4
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 59 deletions.
10 changes: 5 additions & 5 deletions folly/io/IOBuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ IOBuf& IOBuf::operator=(const IOBuf& other) {
return *this;
}

bool IOBuf::empty() const {
bool IOBuf::empty() const noexcept {
const IOBuf* current = this;
do {
if (current->length() != 0) {
Expand All @@ -681,23 +681,23 @@ bool IOBuf::empty() const {
return true;
}

size_t IOBuf::countChainElements() const {
size_t IOBuf::countChainElements() const noexcept {
size_t numElements = 1;
for (IOBuf* current = next_; current != this; current = current->next_) {
++numElements;
}
return numElements;
}

std::size_t IOBuf::computeChainDataLength() const {
std::size_t IOBuf::computeChainDataLength() const noexcept {
std::size_t fullLength = length_;
for (IOBuf* current = next_; current != this; current = current->next_) {
fullLength += current->length_;
}
return fullLength;
}

std::size_t IOBuf::computeChainCapacity() const {
std::size_t IOBuf::computeChainCapacity() const noexcept {
std::size_t fullCapacity = capacity_;
for (IOBuf* current = next_; current != this; current = current->next_) {
fullCapacity += current->capacity_;
Expand Down Expand Up @@ -1411,7 +1411,7 @@ IOBuf::FillIovResult IOBuf::fillIov(struct iovec* iov, size_t len) const {
return {0, 0};
}

uint32_t IOBuf::approximateShareCountOne() const {
uint32_t IOBuf::approximateShareCountOne() const noexcept {
if (FOLLY_UNLIKELY(!sharedInfo_)) {
return 1U;
}
Expand Down
66 changes: 35 additions & 31 deletions folly/io/IOBuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -776,14 +776,14 @@ class IOBuf {
*
* @methodset Chaining
*/
bool empty() const;
bool empty() const noexcept;

/**
* Get the pointer to the start of the data.
*
* @methodset Access
*/
const uint8_t* data() const { return data_; }
const uint8_t* data() const noexcept { return data_; }

/**
* Get a writable pointer to the start of the data.
Expand All @@ -793,14 +793,14 @@ class IOBuf {
*
* @methodset Access
*/
uint8_t* writableData() { return data_; }
uint8_t* writableData() noexcept { return data_; }

/**
* Get the pointer to the end of the data.
*
* @methodset Access
*/
const uint8_t* tail() const { return data_ + length_; }
const uint8_t* tail() const noexcept { return data_ + length_; }

/**
* Get a writable pointer to the end of the data.
Expand All @@ -810,7 +810,7 @@ class IOBuf {
*
* @methodset Access
*/
uint8_t* writableTail() { return data_ + length_; }
uint8_t* writableTail() noexcept { return data_ + length_; }

/**
* Get the size of the data for this individual IOBuf in the chain.
Expand All @@ -819,7 +819,7 @@ class IOBuf {
*
* @methodset Buffer Capacity
*/
std::size_t length() const { return length_; }
std::size_t length() const noexcept { return length_; }

/**
* Get the amount of head room.
Expand All @@ -828,7 +828,9 @@ class IOBuf {
*
* @methodset Buffer Capacity
*/
std::size_t headroom() const { return std::size_t(data_ - buffer()); }
std::size_t headroom() const noexcept {
return std::size_t(data_ - buffer());
}

/**
* Get the amount of tail room.
Expand All @@ -837,7 +839,9 @@ class IOBuf {
*
* @methodset Buffer Capacity
*/
std::size_t tailroom() const { return std::size_t(bufferEnd() - tail()); }
std::size_t tailroom() const noexcept {
return std::size_t(bufferEnd() - tail());
}

/**
* Get the pointer to the start of the buffer.
Expand All @@ -848,7 +852,7 @@ class IOBuf {
*
* @methodset Access
*/
const uint8_t* buffer() const { return buf_; }
const uint8_t* buffer() const noexcept { return buf_; }

/**
* Get a writable pointer to the start of the buffer.
Expand All @@ -858,7 +862,7 @@ class IOBuf {
*
* @methodset Access
*/
uint8_t* writableBuffer() { return buf_; }
uint8_t* writableBuffer() noexcept { return buf_; }

/**
* Get the pointer to the end of the buffer.
Expand All @@ -869,7 +873,7 @@ class IOBuf {
*
* @methodset Access
*/
const uint8_t* bufferEnd() const { return buf_ + capacity_; }
const uint8_t* bufferEnd() const noexcept { return buf_ + capacity_; }

/**
* Get the total size of the buffer.
Expand All @@ -879,25 +883,25 @@ class IOBuf {
*
* @methodset Buffer Capacity
*/
std::size_t capacity() const { return capacity_; }
std::size_t capacity() const noexcept { return capacity_; }

/**
* Get a pointer to the next IOBuf in this chain.
*
* @methodset Chaining
*/
IOBuf* next() { return next_; }
IOBuf* next() noexcept { return next_; }
/// @copydoc next()
const IOBuf* next() const { return next_; }
const IOBuf* next() const noexcept { return next_; }

/**
* Get a pointer to the previous IOBuf in this chain.
*
* @methodset Chaining
*/
IOBuf* prev() { return prev_; }
IOBuf* prev() noexcept { return prev_; }
/// @copydoc prev
const IOBuf* prev() const { return prev_; }
const IOBuf* prev() const noexcept { return prev_; }

/**
* Shift the data forwards in the buffer.
Expand All @@ -919,7 +923,7 @@ class IOBuf {
*
* @methodset Shifting
*/
void advance(std::size_t amount) {
void advance(std::size_t amount) noexcept {
// In debug builds, assert if there is a problem.
assert(amount <= tailroom());

Expand Down Expand Up @@ -948,7 +952,7 @@ class IOBuf {
*
* @methodset Shifting
*/
void retreat(std::size_t amount) {
void retreat(std::size_t amount) noexcept {
// In debug builds, assert if there is a problem.
assert(amount <= headroom());

Expand All @@ -973,7 +977,7 @@ class IOBuf {
*
* @methodset Shifting
*/
void prepend(std::size_t amount) {
void prepend(std::size_t amount) noexcept {
DCHECK_LE(amount, headroom());
data_ -= amount;
length_ += amount;
Expand All @@ -994,7 +998,7 @@ class IOBuf {
*
* @methodset Shifting
*/
void append(std::size_t amount) {
void append(std::size_t amount) noexcept {
DCHECK_LE(amount, tailroom());
length_ += amount;
}
Expand All @@ -1013,7 +1017,7 @@ class IOBuf {
*
* @methodset Shifting
*/
void trimStart(std::size_t amount) {
void trimStart(std::size_t amount) noexcept {
DCHECK_LE(amount, length_);
data_ += amount;
length_ -= amount;
Expand All @@ -1033,7 +1037,7 @@ class IOBuf {
*
* @methodset Shifting
*/
void trimEnd(std::size_t amount) {
void trimEnd(std::size_t amount) noexcept {
DCHECK_LE(amount, length_);
length_ -= amount;
}
Expand All @@ -1049,7 +1053,7 @@ class IOBuf {
*
* @methodset Shifting
*/
void trimWritableTail(std::size_t amount) {
void trimWritableTail(std::size_t amount) noexcept {
DCHECK_LE(amount, tailroom());
capacity_ -= amount;
}
Expand All @@ -1060,7 +1064,7 @@ class IOBuf {
* @post data() == buffer()
* @post length() == 0
*/
void clear() {
void clear() noexcept {
data_ = writableBuffer();
length_ = 0;
}
Expand Down Expand Up @@ -1109,7 +1113,7 @@ class IOBuf {
*
* @methodset Chaining
*/
bool isChained() const {
bool isChained() const noexcept {
assert((next_ == this) == (prev_ == this));
return next_ != this;
}
Expand All @@ -1123,7 +1127,7 @@ class IOBuf {
*
* @methodset Chaining
*/
size_t countChainElements() const;
size_t countChainElements() const noexcept;

/**
* Get the length of all the data in this IOBuf chain.
Expand All @@ -1132,7 +1136,7 @@ class IOBuf {
*
* @methodset Chaining
*/
std::size_t computeChainDataLength() const;
std::size_t computeChainDataLength() const noexcept;

/**
* Get the capacity all IOBufs in the chain.
Expand All @@ -1141,7 +1145,7 @@ class IOBuf {
*
* @methodset Chaining
*/
std::size_t computeChainCapacity() const;
std::size_t computeChainCapacity() const noexcept;

/**
* Append another IOBuf chain to the end of this chain.
Expand Down Expand Up @@ -1302,7 +1306,7 @@ class IOBuf {
*
* @methodset Buffer Management
*/
bool isShared() const {
bool isShared() const noexcept {
const IOBuf* current = this;
while (true) {
if (current->isSharedOne()) {
Expand Down Expand Up @@ -1385,7 +1389,7 @@ class IOBuf {
*
* @methodset Buffer Management
*/
bool isManaged() const {
bool isManaged() const noexcept {
const IOBuf* current = this;
while (true) {
if (!current->isManagedOne()) {
Expand Down Expand Up @@ -1429,7 +1433,7 @@ class IOBuf {
*
* @methodset Buffer Management
*/
uint32_t approximateShareCountOne() const;
uint32_t approximateShareCountOne() const noexcept;

/**
* Check if the buffer is shared.
Expand Down
2 changes: 1 addition & 1 deletion folly/io/IOBufQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ IOBufQueue::IOBufQueue(IOBufQueue&& other) noexcept
localCache_.attached = true;
}

IOBufQueue& IOBufQueue::operator=(IOBufQueue&& other) {
IOBufQueue& IOBufQueue::operator=(IOBufQueue&& other) noexcept {
if (&other != this) {
other.clearWritableRangeCache();
clearWritableRangeCache();
Expand Down
Loading

0 comments on commit 8c449c4

Please sign in to comment.