[*] Minor WakeOnAddress optimization

This commit is contained in:
Reece Wilson 2023-11-29 05:34:57 +00:00
parent 541f12acfb
commit f06248f687

View File

@ -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
{