1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +00:00

AK: Use __builtin_memset() and such to reduce header dependencies

We can use __builtin_memset() without including <string.h>.
This is pretty neat, as it will allow us to reduce the header deps
of AK templates a bit, if applied consistently.

Note that this is an enabling change for an upcoming #include removal.
This commit is contained in:
Andreas Kling 2020-03-08 11:57:24 +01:00
parent b1058b33fb
commit 35d88f536c
5 changed files with 14 additions and 14 deletions

View file

@ -96,7 +96,7 @@ public:
if (!count)
return;
if constexpr (Traits<T>::is_trivial()) {
memmove(destination, source, count * sizeof(T));
__builtin_memmove(destination, source, count * sizeof(T));
return;
}
for (size_t i = 0; i < count; ++i)
@ -108,7 +108,7 @@ public:
if (!count)
return;
if constexpr (Traits<T>::is_trivial()) {
memmove(destination, source, count * sizeof(T));
__builtin_memmove(destination, source, count * sizeof(T));
return;
}
for (size_t i = 0; i < count; ++i)
@ -121,7 +121,7 @@ public:
return true;
if constexpr (Traits<T>::is_trivial())
return !memcmp(a, b, count * sizeof(T));
return !__builtin_memcmp(a, b, count * sizeof(T));
for (size_t i = 0; i < count; ++i) {
if (a[i] != b[i])
@ -641,7 +641,7 @@ private:
size_t m_size { 0 };
size_t m_capacity { 0 };
alignas(T) u8 m_inline_buffer_storage[sizeof(T) * inline_capacity];
alignas(T) unsigned char m_inline_buffer_storage[sizeof(T) * inline_capacity];
T* m_outline_buffer { nullptr };
};