From f06248f6876420506cff052b01ff9dd67e227a50 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Wed, 29 Nov 2023 05:34:57 +0000 Subject: [PATCH] [*] Minor WakeOnAddress optimization --- Source/Threading/AuWakeOnAddress.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Source/Threading/AuWakeOnAddress.cpp b/Source/Threading/AuWakeOnAddress.cpp index e7b00856..295a3254 100644 --- a/Source/Threading/AuWakeOnAddress.cpp +++ b/Source/Threading/AuWakeOnAddress.cpp @@ -234,19 +234,31 @@ namespace Aurora::Threading bool WaitBuffer::Compare(const void *pBuf, AuUInt8 uSize, const void *pBuf2) { - return AuMemcmp(pBuf, pBuf2, uSize) == 0; + switch (uSize) + { + case 1: + return AuReadU8(pBuf, 0) == AuReadU8(pBuf2, 0); + case 2: + return AuReadU16(pBuf, 0) == AuReadU16(pBuf2, 0); + case 4: + return AuReadU32(pBuf, 0) == AuReadU32(pBuf2, 0); + case 8: + return AuReadU64(pBuf, 0) == AuReadU64(pBuf2, 0); + default: + return AuMemcmp(pBuf, pBuf2, uSize) == 0; + } } bool WaitBuffer::Compare(const void *pBuf) { - return AuMemcmp(this->buffer, pBuf, this->uSize) == 0; + return WaitBuffer::Compare(this->buffer, this->uSize, pBuf); } bool WaitBuffer::Compare(WaitState &state) { if (!state.uDownsizeMask) { - return AuMemcmp(this->buffer, state.compare.buffer, AuMin(this->uSize, state.compare.uSize)) == 0; + return WaitBuffer::Compare(this->buffer, AuMin(this->uSize, state.compare.uSize), state.compare.buffer); } else { @@ -277,11 +289,8 @@ namespace Aurora::Threading Lock(); if (auto pLoadFromMemory = this->waitList.pHead) { - if (pLoadFromMemory != pReturn) - { - pReturn->pNext = pLoadFromMemory; - pLoadFromMemory->pBefore = pReturn; - } + pReturn->pNext = pLoadFromMemory; + pLoadFromMemory->pBefore = pReturn; } else {