From 6f38ce8f47f3c086720eb1adc7a855a3bf91a7d1 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 2 Jun 2021 21:26:09 +0200 Subject: [PATCH] Kernel: Avoid allocations in the VMObject constructor This avoids allocations in the VMObject constructor. The number of inline elements was determined empirically and covers most common cases including LibC malloc. --- Kernel/VM/VMObject.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Kernel/VM/VMObject.h b/Kernel/VM/VMObject.h index 493708aaef0..64de251ef69 100644 --- a/Kernel/VM/VMObject.h +++ b/Kernel/VM/VMObject.h @@ -42,8 +42,8 @@ public: virtual bool is_contiguous() const { return false; } size_t page_count() const { return m_physical_pages.size(); } - const Vector>& physical_pages() const { return m_physical_pages; } - Vector>& physical_pages() { return m_physical_pages; } + const Vector, 16>& physical_pages() const { return m_physical_pages; } + Vector, 16>& physical_pages() { return m_physical_pages; } size_t size() const { return m_physical_pages.size() * PAGE_SIZE; } @@ -71,7 +71,7 @@ protected: void for_each_region(Callback); IntrusiveListNode m_list_node; - Vector> m_physical_pages; + Vector, 16> m_physical_pages; Lock m_paging_lock { "VMObject" }; mutable SpinLock m_lock;