Remove redundant if:

currentBlock and prevPhysical block can't be free at the same time at this moment.
This commit is contained in:
Pavel Gribov 2025-01-25 23:24:45 +03:00
parent 72c309a83b
commit 4ad5e3b4c1

View file

@ -9318,29 +9318,12 @@ void VmaBlockMetadata_TLSF::Alloc(
VkDeviceSize debugMargin = GetDebugMargin();
VkDeviceSize missingAlignment = offset - currentBlock->offset;
// Append missing alignment to prev block or create new one
// Create new block for missing alignment
if (missingAlignment)
{
Block* prevBlock = currentBlock->prevPhysical;
VMA_ASSERT(prevBlock != VMA_NULL && "There should be no missing alignment at offset 0!");
if (prevBlock->IsFree() && prevBlock->size != debugMargin)
{
uint32_t oldList = GetListIndex(prevBlock->size);
prevBlock->size += missingAlignment;
// Check if new size crosses list bucket
if (oldList != GetListIndex(prevBlock->size))
{
prevBlock->size -= missingAlignment;
RemoveFreeBlock(prevBlock);
prevBlock->size += missingAlignment;
InsertFreeBlock(prevBlock);
}
else
m_BlocksFreeSize += missingAlignment;
}
else
{
Block* newBlock = m_BlockAllocator.Alloc();
currentBlock->prevPhysical = newBlock;
prevBlock->nextPhysical = newBlock;
@ -9349,9 +9332,7 @@ void VmaBlockMetadata_TLSF::Alloc(
newBlock->size = missingAlignment;
newBlock->offset = currentBlock->offset;
newBlock->MarkTaken();
InsertFreeBlock(newBlock);
}
currentBlock->size -= missingAlignment;
currentBlock->offset += missingAlignment;