LibJS: Always inline HeapBlock::allocate()

This thing is so simple and sits on the hot path so just inline it.
This commit is contained in:
Andreas Kling 2020-10-04 18:11:54 +02:00
parent ad0d377e4c
commit 2852ce4954
Notes: sideshowbarker 2024-07-19 02:03:33 +09:00
2 changed files with 7 additions and 8 deletions
Libraries/LibJS/Heap

View file

@ -73,13 +73,6 @@ HeapBlock::HeapBlock(Heap& heap, size_t cell_size)
m_freelist = next;
}
Cell* HeapBlock::allocate()
{
if (!m_freelist)
return nullptr;
return exchange(m_freelist, m_freelist->next);
}
void HeapBlock::deallocate(Cell* cell)
{
ASSERT(cell->is_live());

View file

@ -42,7 +42,13 @@ public:
size_t cell_size() const { return m_cell_size; }
size_t cell_count() const { return (block_size - sizeof(HeapBlock)) / m_cell_size; }
Cell* allocate();
ALWAYS_INLINE Cell* allocate()
{
if (!m_freelist)
return nullptr;
return exchange(m_freelist, m_freelist->next);
}
void deallocate(Cell*);
template<typename Callback>