mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 18:02:20 +00:00
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: 2852ce4954
2 changed files with 7 additions and 8 deletions
|
@ -73,13 +73,6 @@ HeapBlock::HeapBlock(Heap& heap, size_t cell_size)
|
||||||
m_freelist = next;
|
m_freelist = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cell* HeapBlock::allocate()
|
|
||||||
{
|
|
||||||
if (!m_freelist)
|
|
||||||
return nullptr;
|
|
||||||
return exchange(m_freelist, m_freelist->next);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HeapBlock::deallocate(Cell* cell)
|
void HeapBlock::deallocate(Cell* cell)
|
||||||
{
|
{
|
||||||
ASSERT(cell->is_live());
|
ASSERT(cell->is_live());
|
||||||
|
|
|
@ -42,7 +42,13 @@ public:
|
||||||
size_t cell_size() const { return m_cell_size; }
|
size_t cell_size() const { return m_cell_size; }
|
||||||
size_t cell_count() const { return (block_size - sizeof(HeapBlock)) / 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*);
|
void deallocate(Cell*);
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue