mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 17:31:58 -05:00
AK: Use TypedTransfer in Span::copy_to.
This commit is contained in:
parent
910924f559
commit
a7f786fc0a
1 changed files with 12 additions and 6 deletions
18
AK/Span.h
18
AK/Span.h
|
@ -27,8 +27,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/Checked.h>
|
||||
#include <AK/Iterator.h>
|
||||
#include <AK/TypedTransfer.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace AK {
|
||||
|
@ -156,15 +156,13 @@ public:
|
|||
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();
|
||||
return TypedTransfer<typename RemoveConst<T>::Type>::copy(other.data(), data(), size());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE size_t copy_trimmed_to(Span<typename RemoveConst<T>::Type> other) const
|
||||
{
|
||||
auto count = min(size(), other.size());
|
||||
__builtin_memmove(other.data(), data(), sizeof(T) * count);
|
||||
return count;
|
||||
const auto count = min(size(), other.size());
|
||||
return TypedTransfer<typename RemoveConst<T>::Type>::copy(other.data(), data(), count);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void fill(const T& value)
|
||||
|
@ -210,6 +208,14 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(Span<T> other) const
|
||||
{
|
||||
if (size() != other.size())
|
||||
return false;
|
||||
|
||||
return TypedTransfer<T>::compare(data(), other.data(), size());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE operator Span<const T>() const
|
||||
{
|
||||
return { data(), size() };
|
||||
|
|
Loading…
Reference in a new issue