From 5638a6a900f35587e9475493cf3d682e3c89782b Mon Sep 17 00:00:00 2001 From: Saman <100295082+enum-class@users.noreply.github.com> Date: Sun, 8 Jan 2023 11:40:03 +0800 Subject: [PATCH] Minor improvement (#7766) --- include/flatbuffers/detached_buffer.h | 4 ++-- include/flatbuffers/flatbuffer_builder.h | 4 ++-- include/flatbuffers/flexbuffers.h | 2 +- include/flatbuffers/vector_downward.h | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/flatbuffers/detached_buffer.h b/include/flatbuffers/detached_buffer.h index 760a08845..5e900baeb 100644 --- a/include/flatbuffers/detached_buffer.h +++ b/include/flatbuffers/detached_buffer.h @@ -45,7 +45,7 @@ class DetachedBuffer { cur_(cur), size_(sz) {} - DetachedBuffer(DetachedBuffer &&other) + DetachedBuffer(DetachedBuffer &&other) noexcept : allocator_(other.allocator_), own_allocator_(other.own_allocator_), buf_(other.buf_), @@ -55,7 +55,7 @@ class DetachedBuffer { other.reset(); } - DetachedBuffer &operator=(DetachedBuffer &&other) { + DetachedBuffer &operator=(DetachedBuffer &&other) noexcept { if (this == &other) return *this; destroy(); diff --git a/include/flatbuffers/flatbuffer_builder.h b/include/flatbuffers/flatbuffer_builder.h index 090a60e4f..a1d3d60a7 100644 --- a/include/flatbuffers/flatbuffer_builder.h +++ b/include/flatbuffers/flatbuffer_builder.h @@ -98,7 +98,7 @@ class FlatBufferBuilder { } /// @brief Move constructor for FlatBufferBuilder. - FlatBufferBuilder(FlatBufferBuilder &&other) + FlatBufferBuilder(FlatBufferBuilder &&other) noexcept : buf_(1024, nullptr, false, AlignOf()), num_field_loc(0), max_voffset_(0), @@ -116,7 +116,7 @@ class FlatBufferBuilder { } /// @brief Move assignment operator for FlatBufferBuilder. - FlatBufferBuilder &operator=(FlatBufferBuilder &&other) { + FlatBufferBuilder &operator=(FlatBufferBuilder &&other) noexcept { // Move construct a temporary and swap idiom FlatBufferBuilder temp(std::move(other)); Swap(temp); diff --git a/include/flatbuffers/flexbuffers.h b/include/flatbuffers/flexbuffers.h index dd35b87dc..a0ee67003 100644 --- a/include/flatbuffers/flexbuffers.h +++ b/include/flatbuffers/flexbuffers.h @@ -1845,7 +1845,7 @@ class Verifier FLATBUFFERS_FINAL_CLASS { uint8_t len = 0; auto vtype = ToFixedTypedVectorElementType(r.type_, &len); if (!VerifyType(vtype)) return false; - return VerifyFromPointer(p, r.byte_width_ * len); + return VerifyFromPointer(p, static_cast(r.byte_width_) * len); } default: return false; } diff --git a/include/flatbuffers/vector_downward.h b/include/flatbuffers/vector_downward.h index 2dbaa6005..e0aed840b 100644 --- a/include/flatbuffers/vector_downward.h +++ b/include/flatbuffers/vector_downward.h @@ -45,7 +45,7 @@ class vector_downward { cur_(nullptr), scratch_(nullptr) {} - vector_downward(vector_downward &&other) + vector_downward(vector_downward &&other) noexcept // clang-format on : allocator_(other.allocator_), own_allocator_(other.own_allocator_), @@ -66,7 +66,7 @@ class vector_downward { other.scratch_ = nullptr; } - vector_downward &operator=(vector_downward &&other) { + vector_downward &operator=(vector_downward &&other) noexcept { // Move construct a temporary and swap idiom vector_downward temp(std::move(other)); swap(temp);