summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorkleines Filmröllchen <malu.bertsch@gmail.com>2021-12-17 12:36:25 +0100
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-12-17 13:13:00 -0800
commit3891d6d73afd6408314eeb27713dad0f45718310 (patch)
tree6235344930c9eadb3a0886e03c7da054cb5cb98b /AK
parentd5dce448ea679e40348ac77869f73374d3c89ae6 (diff)
downloadserenity-3891d6d73afd6408314eeb27713dad0f45718310.zip
AK: Fast path for single-element TypedTransfer::copy
Co-Authored-By: Brian Gianforcaro <bgianf@serenityos.org>
Diffstat (limited to 'AK')
-rw-r--r--AK/TypedTransfer.h5
1 files changed, 4 insertions, 1 deletions
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<T>::is_trivial()) {
- __builtin_memmove(destination, source, count * sizeof(T));
+ if (count == 1)
+ *destination = *source;
+ else
+ __builtin_memmove(destination, source, count * sizeof(T));
return count;
}