0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 02:02:38 +01:00

ircd:🆑 Inline various move semantics; fix data::mapped move.

This commit is contained in:
Jason Volk 2022-03-21 15:18:08 -07:00
parent 1a29e591ef
commit 3e7875e314
4 changed files with 80 additions and 65 deletions

View file

@ -38,3 +38,21 @@ struct ircd::cl::code
code &operator=(code &&) noexcept;
~code() noexcept;
};
inline
ircd::cl::code::code(code &&o)
noexcept
:handle{std::move(o.handle)}
{
o.handle = nullptr;
}
inline ircd::cl::code &
ircd::cl::code::operator=(code &&o)
noexcept
{
this->~code();
handle = std::move(o.handle);
o.handle = nullptr;
return *this;
}

View file

@ -40,3 +40,45 @@ struct ircd::cl::data
data &operator=(data &&) noexcept;
~data() noexcept;
};
inline
ircd::cl::data::data(data &&o)
noexcept
:handle{std::move(o.handle)}
,mapped{std::move(o.mapped)}
{
o.handle = nullptr;
o.mapped = nullptr;
}
inline ircd::cl::data &
ircd::cl::data::operator=(data &&o)
noexcept
{
this->~data();
handle = std::move(o.handle);
mapped = std::move(o.mapped);
o.handle = nullptr;
o.mapped = nullptr;
return *this;
}
inline ircd::cl::data::operator
mutable_buffer()
const
{
return
{
ptr(), size()
};
}
inline ircd::cl::data::operator
const_buffer()
const
{
return
{
ptr(), size()
};
}

View file

@ -61,6 +61,24 @@ ircd::cl::kern::kern(code &c,
(this->arg(i++, a), ...);
}
inline
ircd::cl::kern::kern(kern &&o)
noexcept
:handle{std::move(o.handle)}
{
o.handle = nullptr;
}
inline ircd::cl::kern &
ircd::cl::kern::operator=(kern &&o)
noexcept
{
this->~kern();
handle = std::move(o.handle);
o.handle = nullptr;
return *this;
}
template<class T>
inline void
ircd::cl::kern::arg(const int pos,

View file

@ -1197,23 +1197,6 @@ catch(const std::exception &e)
throw;
}
ircd::cl::kern::kern(kern &&o)
noexcept
:handle{std::move(o.handle)}
{
o.handle = nullptr;
}
ircd::cl::kern &
ircd::cl::kern::operator=(kern &&o)
noexcept
{
this->~kern();
handle = std::move(o.handle);
o.handle = nullptr;
return *this;
}
ircd::cl::kern::~kern()
noexcept try
{
@ -1437,23 +1420,6 @@ ircd::cl::code::code(const vector_view<const const_buffer> &bins)
throw_on_error(binerr[i]);
}
ircd::cl::code::code(code &&o)
noexcept
:handle{std::move(o.handle)}
{
o.handle = nullptr;
}
ircd::cl::code &
ircd::cl::code::operator=(code &&o)
noexcept
{
this->~code();
handle = std::move(o.handle);
o.handle = nullptr;
return *this;
}
ircd::cl::code::~code()
noexcept try
{
@ -2034,26 +2000,11 @@ ircd::cl::data::data(data &master,
throw_on_error(err);
}
ircd::cl::data::data(data &&o)
noexcept
:handle{std::move(o.handle)}
{
o.handle = nullptr;
}
ircd::cl::data &
ircd::cl::data::operator=(data &&o)
noexcept
{
this->~data();
handle = std::move(o.handle);
o.handle = nullptr;
return *this;
}
ircd::cl::data::~data()
noexcept try
{
assert(handle || !mapped);
if(likely(handle))
{
const auto size
@ -2078,20 +2029,6 @@ catch(const std::exception &e)
return;
}
ircd::cl::data::operator
mutable_buffer()
const
{
return { ptr(), size() };
}
ircd::cl::data::operator
const_buffer()
const
{
return { ptr(), size() };
}
char *
ircd::cl::data::ptr()
const