mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:47:35 +00:00
AK: Add copy_to() and move_to() methods to AK::Span.
This commit is contained in:
parent
8e7dfebf11
commit
78849bbb48
1 changed files with 22 additions and 0 deletions
22
AK/Span.h
22
AK/Span.h
|
@ -154,6 +154,28 @@ public:
|
||||||
return this->m_values + start;
|
return this->m_values + start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ALWAYS_INLINE void copy_to(Span other) const
|
||||||
|
{
|
||||||
|
ASSERT(other.size() >= size());
|
||||||
|
__builtin_memcpy(other.data(), data(), sizeof(T) * size());
|
||||||
|
}
|
||||||
|
|
||||||
|
ALWAYS_INLINE void copy_trimmed_to(Span other) const
|
||||||
|
{
|
||||||
|
__builtin_memcpy(other.data(), data(), sizeof(T) * min(size(), other.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
ALWAYS_INLINE void move_to(Span other) const
|
||||||
|
{
|
||||||
|
ASSERT(other.size() >= size());
|
||||||
|
__builtin_memmove(other.data(), data(), sizeof(T) * size());
|
||||||
|
}
|
||||||
|
|
||||||
|
ALWAYS_INLINE void move_trimmed_to(Span other) const
|
||||||
|
{
|
||||||
|
__builtin_memmove(other.data(), data(), sizeof(T) * min(size(), other.size()));
|
||||||
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE const T& at(size_t index) const
|
ALWAYS_INLINE const T& at(size_t index) const
|
||||||
{
|
{
|
||||||
ASSERT(index < this->m_size);
|
ASSERT(index < this->m_size);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue