Skip to content

Commit

Permalink
value,reference,module_loader: Use rocket::exchange()
Browse files Browse the repository at this point in the history
  • Loading branch information
lhmouse committed Oct 17, 2023
1 parent 4112471 commit ca1a8f6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
12 changes: 4 additions & 8 deletions asteria/runtime/module_loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,10 @@ class Module_Loader::Unique_Stream
Unique_Stream&
do_reset(const refcnt_ptr<Module_Loader>& loader, locked_stream_pair* strm) noexcept
{
auto qloader = ::std::exchange(this->m_loader, loader);
auto qstrm = ::std::exchange(this->m_strm, strm);
if(!qstrm)
return *this;

// Unlock the old stream if one has been assigned.
ROCKET_ASSERT(qloader);
qloader->do_unlock_stream(qstrm);
auto qloader = ::rocket::exchange(this->m_loader, loader);
auto qstrm = ::rocket::exchange(this->m_strm, strm);
if(qloader && qstrm)
qloader->do_unlock_stream(qstrm);
return *this;
}

Expand Down
4 changes: 2 additions & 2 deletions asteria/runtime/reference.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Reference
m_var(::std::move(other.m_var)),
m_ptc(::std::move(other.m_ptc)),
m_mods(::std::move(other.m_mods)),
m_xref(::std::exchange(other.m_xref, xref_invalid))
m_xref(::rocket::exchange(other.m_xref))
{
if(this->m_xref == xref_temporary)
this->m_value = ::std::move(other.m_value);
Expand All @@ -73,7 +73,7 @@ class Reference
this->m_ptc = ::std::move(other.m_ptc);

this->m_mods = ::std::move(other.m_mods);
this->m_xref = ::std::exchange(other.m_xref, xref_invalid);
this->m_xref = ::rocket::exchange(other.m_xref);
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion asteria/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Value

Value(Value&& other) noexcept
:
m_bytes(::std::exchange(other.m_bytes, bytes_type())) // HACK
m_bytes(::rocket::exchange(other.m_bytes)) // HACK
{
}

Expand Down

0 comments on commit ca1a8f6

Please sign in to comment.