From a7f786fc0a957321883558aeb593e9c8b92db2df Mon Sep 17 00:00:00 2001 From: asynts Date: Wed, 9 Sep 2020 13:44:51 +0200 Subject: [PATCH] AK: Use TypedTransfer in Span::copy_to. --- AK/Span.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/AK/Span.h b/AK/Span.h index 68321cede4..f4512a0c15 100644 --- a/AK/Span.h +++ b/AK/Span.h @@ -27,8 +27,8 @@ #pragma once #include -#include #include +#include #include namespace AK { @@ -156,15 +156,13 @@ public: ALWAYS_INLINE size_t copy_to(Span::Type> other) const { ASSERT(other.size() >= size()); - __builtin_memmove(other.data(), data(), sizeof(T) * size()); - return size(); + return TypedTransfer::Type>::copy(other.data(), data(), size()); } ALWAYS_INLINE size_t copy_trimmed_to(Span::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::Type>::copy(other.data(), data(), count); } ALWAYS_INLINE void fill(const T& value) @@ -210,6 +208,14 @@ public: return *this; } + bool operator==(Span other) const + { + if (size() != other.size()) + return false; + + return TypedTransfer::compare(data(), other.data(), size()); + } + ALWAYS_INLINE operator Span() const { return { data(), size() };