diff options
author | Andreas Kling <kling@serenityos.org> | 2020-10-04 18:11:54 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-04 19:25:49 +0200 |
commit | 2852ce4954f76f657d0170b162bff12836d27e40 (patch) | |
tree | fc1f1f3f6fa40f1a196c5c7888f52c24dccf9213 /Libraries | |
parent | ad0d377e4c6d9ddfc6d9da7e7e3fe1dd55a7eb38 (diff) | |
download | serenity-2852ce4954f76f657d0170b162bff12836d27e40.zip |
LibJS: Always inline HeapBlock::allocate()
This thing is so simple and sits on the hot path so just inline it.
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibJS/Heap/HeapBlock.cpp | 7 | ||||
-rw-r--r-- | 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<typename Callback> |