mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-06 21:26:28 +00:00
Minor improvement (#7766)
This commit is contained in:
@@ -45,7 +45,7 @@ class DetachedBuffer {
|
|||||||
cur_(cur),
|
cur_(cur),
|
||||||
size_(sz) {}
|
size_(sz) {}
|
||||||
|
|
||||||
DetachedBuffer(DetachedBuffer &&other)
|
DetachedBuffer(DetachedBuffer &&other) noexcept
|
||||||
: allocator_(other.allocator_),
|
: allocator_(other.allocator_),
|
||||||
own_allocator_(other.own_allocator_),
|
own_allocator_(other.own_allocator_),
|
||||||
buf_(other.buf_),
|
buf_(other.buf_),
|
||||||
@@ -55,7 +55,7 @@ class DetachedBuffer {
|
|||||||
other.reset();
|
other.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
DetachedBuffer &operator=(DetachedBuffer &&other) {
|
DetachedBuffer &operator=(DetachedBuffer &&other) noexcept {
|
||||||
if (this == &other) return *this;
|
if (this == &other) return *this;
|
||||||
|
|
||||||
destroy();
|
destroy();
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ class FlatBufferBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Move constructor for FlatBufferBuilder.
|
/// @brief Move constructor for FlatBufferBuilder.
|
||||||
FlatBufferBuilder(FlatBufferBuilder &&other)
|
FlatBufferBuilder(FlatBufferBuilder &&other) noexcept
|
||||||
: buf_(1024, nullptr, false, AlignOf<largest_scalar_t>()),
|
: buf_(1024, nullptr, false, AlignOf<largest_scalar_t>()),
|
||||||
num_field_loc(0),
|
num_field_loc(0),
|
||||||
max_voffset_(0),
|
max_voffset_(0),
|
||||||
@@ -116,7 +116,7 @@ class FlatBufferBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Move assignment operator for FlatBufferBuilder.
|
/// @brief Move assignment operator for FlatBufferBuilder.
|
||||||
FlatBufferBuilder &operator=(FlatBufferBuilder &&other) {
|
FlatBufferBuilder &operator=(FlatBufferBuilder &&other) noexcept {
|
||||||
// Move construct a temporary and swap idiom
|
// Move construct a temporary and swap idiom
|
||||||
FlatBufferBuilder temp(std::move(other));
|
FlatBufferBuilder temp(std::move(other));
|
||||||
Swap(temp);
|
Swap(temp);
|
||||||
|
|||||||
@@ -1845,7 +1845,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS {
|
|||||||
uint8_t len = 0;
|
uint8_t len = 0;
|
||||||
auto vtype = ToFixedTypedVectorElementType(r.type_, &len);
|
auto vtype = ToFixedTypedVectorElementType(r.type_, &len);
|
||||||
if (!VerifyType(vtype)) return false;
|
if (!VerifyType(vtype)) return false;
|
||||||
return VerifyFromPointer(p, r.byte_width_ * len);
|
return VerifyFromPointer(p, static_cast<size_t>(r.byte_width_) * len);
|
||||||
}
|
}
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class vector_downward {
|
|||||||
cur_(nullptr),
|
cur_(nullptr),
|
||||||
scratch_(nullptr) {}
|
scratch_(nullptr) {}
|
||||||
|
|
||||||
vector_downward(vector_downward &&other)
|
vector_downward(vector_downward &&other) noexcept
|
||||||
// clang-format on
|
// clang-format on
|
||||||
: allocator_(other.allocator_),
|
: allocator_(other.allocator_),
|
||||||
own_allocator_(other.own_allocator_),
|
own_allocator_(other.own_allocator_),
|
||||||
@@ -66,7 +66,7 @@ class vector_downward {
|
|||||||
other.scratch_ = nullptr;
|
other.scratch_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector_downward &operator=(vector_downward &&other) {
|
vector_downward &operator=(vector_downward &&other) noexcept {
|
||||||
// Move construct a temporary and swap idiom
|
// Move construct a temporary and swap idiom
|
||||||
vector_downward temp(std::move(other));
|
vector_downward temp(std::move(other));
|
||||||
swap(temp);
|
swap(temp);
|
||||||
|
|||||||
Reference in New Issue
Block a user