From 0013fde684e167ee967e0d36c87e829c4c5d19c3 Mon Sep 17 00:00:00 2001 From: Gregory Tsipenyuk Date: Tue, 6 Feb 2024 21:24:51 -0500 Subject: [PATCH] [FOLD] Address @seelabs feedback * Change STObject::set() arg to rvalue ref --- src/ripple/app/misc/impl/AMMUtils.cpp | 2 +- src/ripple/protocol/STObject.h | 2 +- src/ripple/protocol/impl/STObject.cpp | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/ripple/app/misc/impl/AMMUtils.cpp b/src/ripple/app/misc/impl/AMMUtils.cpp index 2511240bfcd..0aead02db88 100644 --- a/src/ripple/app/misc/impl/AMMUtils.cpp +++ b/src/ripple/app/misc/impl/AMMUtils.cpp @@ -314,7 +314,7 @@ initializeFeeAuctionVote( { STObject auctionSlot = STObject::makeInnerObject(sfAuctionSlot, rules); - ammSle->set(&auctionSlot); + ammSle->set(std::move(auctionSlot)); } return ammSle->peekFieldObject(sfAuctionSlot); } diff --git a/src/ripple/protocol/STObject.h b/src/ripple/protocol/STObject.h index 4bf1786cdfb..5476cd01198 100644 --- a/src/ripple/protocol/STObject.h +++ b/src/ripple/protocol/STObject.h @@ -343,7 +343,7 @@ class STObject : public STBase, public CountedObject set(std::unique_ptr v); void - set(STBase* v); + set(STBase&& v); void setFieldU8(SField const& field, unsigned char); diff --git a/src/ripple/protocol/impl/STObject.cpp b/src/ripple/protocol/impl/STObject.cpp index 1778908c489..7c546a2568e 100644 --- a/src/ripple/protocol/impl/STObject.cpp +++ b/src/ripple/protocol/impl/STObject.cpp @@ -645,23 +645,22 @@ STObject::getFieldArray(SField const& field) const void STObject::set(std::unique_ptr v) { - set(v.get()); + set(std::move(*v.get())); } void -STObject::set(STBase* v) +STObject::set(STBase&& v) { - assert(v); - auto const i = getFieldIndex(v->getFName()); + auto const i = getFieldIndex(v.getFName()); if (i != -1) { - v_[i] = std::move(*v); + v_[i] = std::move(v); } else { if (!isFree()) Throw("missing field in templated STObject"); - v_.emplace_back(std::move(*v)); + v_.emplace_back(std::move(v)); } }