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:
parent
ad0d377e4c
commit
2852ce4954
Notes:
sideshowbarker
2024-07-19 02:03:33 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/2852ce4954f
2 changed files with 7 additions and 8 deletions
Libraries/LibJS/Heap
|
@ -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());
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Reference in a new issue