From 2852ce4954f76f657d0170b162bff12836d27e40 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 4 Oct 2020 18:11:54 +0200 Subject: [PATCH] LibJS: Always inline HeapBlock::allocate() This thing is so simple and sits on the hot path so just inline it. --- Libraries/LibJS/Heap/HeapBlock.cpp | 7 ------- Libraries/LibJS/Heap/HeapBlock.h | 8 +++++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Libraries/LibJS/Heap/HeapBlock.cpp b/Libraries/LibJS/Heap/HeapBlock.cpp index 8388934ae4..250fcd6d3c 100644 --- a/Libraries/LibJS/Heap/HeapBlock.cpp +++ b/Libraries/LibJS/Heap/HeapBlock.cpp @@ -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()); diff --git a/Libraries/LibJS/Heap/HeapBlock.h b/Libraries/LibJS/Heap/HeapBlock.h index 3de49c5e28..5b1a4c361b 100644 --- a/Libraries/LibJS/Heap/HeapBlock.h +++ b/Libraries/LibJS/Heap/HeapBlock.h @@ -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