From 46ca7d3cb563c97adcab4838a30e49f5ef64d9f9 Mon Sep 17 00:00:00 2001 From: Ivan Hansgaard Hansen Date: Sun, 21 Feb 2021 15:22:41 +0100 Subject: [PATCH] AK: Alter ByteBuffer to utilise memcmp. __builtin_memcmp is already heavily utilised in AK. --- AK/ByteBuffer.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/AK/ByteBuffer.cpp b/AK/ByteBuffer.cpp index 9e9af19c6d..f2476ac0ce 100644 --- a/AK/ByteBuffer.cpp +++ b/AK/ByteBuffer.cpp @@ -38,15 +38,7 @@ bool ByteBuffer::operator==(const ByteBuffer& other) const return false; // So they both have data, and the same length. - // Avoid hitting conditionals in ever iteration. - size_t n = size(); - const u8* this_data = data(); - const u8* other_data = other.data(); - for (size_t i = 0; i < n; ++i) { - if (this_data[i] != other_data[i]) - return false; - } - return true; + return !__builtin_memcmp(data(), other.data(), size()); } }