Skip to content

Commit

Permalink
[FOLD] Address @seelabs feedback
Browse files Browse the repository at this point in the history
* Change STObject::set() arg to rvalue ref
  • Loading branch information
gregtatcam committed Feb 7, 2024
1 parent 4e6f210 commit 0013fde
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/ripple/app/misc/impl/AMMUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ initializeFeeAuctionVote(
{
STObject auctionSlot =
STObject::makeInnerObject(sfAuctionSlot, rules);
ammSle->set(&auctionSlot);
ammSle->set(std::move(auctionSlot));
}
return ammSle->peekFieldObject(sfAuctionSlot);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/protocol/STObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class STObject : public STBase, public CountedObject<STObject>
set(std::unique_ptr<STBase> v);

void
set(STBase* v);
set(STBase&& v);

void
setFieldU8(SField const& field, unsigned char);
Expand Down
11 changes: 5 additions & 6 deletions src/ripple/protocol/impl/STObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,23 +645,22 @@ STObject::getFieldArray(SField const& field) const
void
STObject::set(std::unique_ptr<STBase> 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<std::runtime_error>("missing field in templated STObject");
v_.emplace_back(std::move(*v));
v_.emplace_back(std::move(v));
}
}

Expand Down

0 comments on commit 0013fde

Please sign in to comment.