diff --git a/.gitignore b/.gitignore index f861e0f8af..ee18e9948c 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ rollups /packages/arb-rpc-node/arb-node /packages/arb-rpc-node/cmd/arb-dev-node/arb-dev-node /packages/arb-rpc-node/cmd/arb-dev-node/arbitrum* +compile_commands.json # Logs logs diff --git a/packages/arb-avm-cpp/.clang-tidy b/packages/arb-avm-cpp/.clang-tidy new file mode 100644 index 0000000000..f87e0b4026 --- /dev/null +++ b/packages/arb-avm-cpp/.clang-tidy @@ -0,0 +1,4 @@ +--- +Checks: '-*,performance-*' +WarningsAsErrors: '*' +FormatStyle: file diff --git a/packages/arb-avm-cpp/avm_values/include/avm_values/buffer.hpp b/packages/arb-avm-cpp/avm_values/include/avm_values/buffer.hpp index 2c727988e8..ad91e8cea9 100644 --- a/packages/arb-avm-cpp/avm_values/include/avm_values/buffer.hpp +++ b/packages/arb-avm-cpp/avm_values/include/avm_values/buffer.hpp @@ -83,7 +83,7 @@ class Buffer : private std::shared_ptr { // Sets bytes at a given offset, growing or shrinking as needed. The bytes // set must be within a single 32 byte chunk. [[nodiscard]] Buffer set_many(uint64_t offset, - std::vector arr) const; + const std::vector& arr) const; // Gets the byte at a given offset [[nodiscard]] uint8_t get(uint64_t pos) const; @@ -150,7 +150,7 @@ class RawBuffer { // Sets bytes at a given offset, growing or shrinking as needed. The bytes // set must be within a single 32 byte chunk. [[nodiscard]] RawBuffer set_many(uint64_t offset, - std::vector arr) const; + const std::vector& arr) const; // Creates a buffer representing the given bytes static RawBuffer fromData(const std::vector& data); diff --git a/packages/arb-avm-cpp/avm_values/src/buffer.cpp b/packages/arb-avm-cpp/avm_values/src/buffer.cpp index 5e456ee547..f106fd2ec2 100644 --- a/packages/arb-avm-cpp/avm_values/src/buffer.cpp +++ b/packages/arb-avm-cpp/avm_values/src/buffer.cpp @@ -48,7 +48,8 @@ const std::vector zero_buffers_of_depth = []() -> std::vector { RawBuffer::RawBuffer(LeafData bytes) : depth(0), components(bytes) {} RawBuffer::RawBuffer(Buffer left, Buffer right) - : depth(left->depth + 1), components(std::make_pair(left, right)) { + : depth(left->depth + 1), + components(std::make_pair(std::move(left), std::move(right))) { auto children = get_children_const(); if (children->first->depth != children->second->depth) { throw new std::runtime_error("Attempted to create uneven buffer"); @@ -238,7 +239,8 @@ uint256_t Buffer::data_length() const { return (*this)->packed_size(); } -RawBuffer RawBuffer::set_many(uint64_t offset, std::vector arr) const { +RawBuffer RawBuffer::set_many(uint64_t offset, + const std::vector& arr) const { RawBuffer ret(*this); if (uint256_t(offset) + arr.size() > ret.size()) { ret = ret.grow(needed_depth(uint256_t(offset) + arr.size())); @@ -393,14 +395,15 @@ std::vector Buffer::serialize( } Buffer::Buffer(RawBuffer raw) - : std::shared_ptr(std::make_shared(raw)) {} + : std::shared_ptr(std::make_shared(std::move(raw))) {} Buffer::Buffer() : Buffer(RawBuffer()) {} Buffer::Buffer(std::array bytes) : Buffer(RawBuffer(bytes)) {} -Buffer::Buffer(Buffer left, Buffer right) : Buffer(RawBuffer(left, right)) {} +Buffer::Buffer(Buffer left, Buffer right) + : Buffer(RawBuffer(std::move(left), std::move(right))) {} Buffer Buffer::fromData(const std::vector& data) { return Buffer(RawBuffer::fromData(data)); @@ -410,6 +413,7 @@ uint256_t Buffer::hash() const { return (*this)->hash(); } -Buffer Buffer::set_many(uint64_t offset, std::vector arr) const { +Buffer Buffer::set_many(uint64_t offset, + const std::vector& arr) const { return Buffer((*this)->set_many(offset, arr)); } diff --git a/packages/arb-avm-cpp/data_storage/src/value/corevalueloader.cpp b/packages/arb-avm-cpp/data_storage/src/value/corevalueloader.cpp index 1d5119aa5d..7154665ddc 100644 --- a/packages/arb-avm-cpp/data_storage/src/value/corevalueloader.cpp +++ b/packages/arb-avm-cpp/data_storage/src/value/corevalueloader.cpp @@ -22,7 +22,9 @@ CoreValueLoader::CoreValueLoader(std::shared_ptr data_storage_, std::shared_ptr core_code_, ValueCache cache_) - : data_storage(data_storage_), core_code(core_code_), cache(cache_) {} + : data_storage(std::move(data_storage_)), + core_code(std::move(core_code_)), + cache(std::move(cache_)) {} value CoreValueLoader::loadValue(const uint256_t& hash) { ReadTransaction tx(data_storage);