From 3891d6d73afd6408314eeb27713dad0f45718310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Fri, 17 Dec 2021 12:36:25 +0100 Subject: [PATCH] AK: Fast path for single-element TypedTransfer::copy Co-Authored-By: Brian Gianforcaro --- AK/TypedTransfer.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/AK/TypedTransfer.h b/AK/TypedTransfer.h index 91045a9da9..64ed7fb274 100644 --- a/AK/TypedTransfer.h +++ b/AK/TypedTransfer.h @@ -37,7 +37,10 @@ public: return 0; if constexpr (Traits::is_trivial()) { - __builtin_memmove(destination, source, count * sizeof(T)); + if (count == 1) + *destination = *source; + else + __builtin_memmove(destination, source, count * sizeof(T)); return count; }