mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
AK: Span: Fix signature of copy_to() and copy_trimmed_to().
Two changes were made
1. copy_to() and copy_trimmed_to() now return how many bytes were
copied.
2. The argument was changed to Span<typename RemoveConst<T>::Type>
because the following would not work:
ReadonlyBytes bytes0;
Bytes bytes1;
// Won't work because this calls Span<const u8>::copy_to(Span<u8>)
// but the method was defined as Span<const u8>::copy_to(Span<const u8>)
bytes0.copy_to(bytes1);
This commit is contained in:
@@ -164,15 +164,18 @@ public:
|
||||
return this->m_values + start;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void copy_to(Span other) const
|
||||
ALWAYS_INLINE size_t copy_to(Span<typename RemoveConst<T>::Type> other) const
|
||||
{
|
||||
ASSERT(other.size() >= size());
|
||||
__builtin_memmove(other.data(), data(), sizeof(T) * size());
|
||||
return size();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void copy_trimmed_to(Span other) const
|
||||
ALWAYS_INLINE size_t copy_trimmed_to(Span<typename RemoveConst<T>::Type> other) const
|
||||
{
|
||||
__builtin_memmove(other.data(), data(), sizeof(T) * min(size(), other.size()));
|
||||
auto count = min(size(), other.size());
|
||||
__builtin_memmove(other.data(), data(), sizeof(T) * count);
|
||||
return count;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void fill(const T& value)
|
||||
|
||||
Reference in New Issue
Block a user