1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:27:45 +00:00

Kernel: Remove unnecessary churn in ConsoleManagement

The maximum number of virtual consoles is determined at compile time,
so we can pre-allocate that many slots, dodging some heap allocations.

Furthermore, virtual consoles are never destroyed, so it's fine to
simply store a raw pointer to the currently active one.
This commit is contained in:
Andreas Kling 2021-08-08 00:44:25 +02:00
parent 652fa54495
commit 2ff3c54153
2 changed files with 6 additions and 6 deletions

View file

@ -20,7 +20,7 @@ class ConsoleManagement {
public:
ConsoleManagement();
static constexpr unsigned s_max_virtual_consoles = 6;
static constexpr size_t s_max_virtual_consoles = 6;
static bool is_initialized();
static ConsoleManagement& the();
@ -38,8 +38,8 @@ public:
RecursiveSpinLock& tty_write_lock() { return m_tty_write_lock; }
private:
NonnullRefPtrVector<VirtualConsole> m_consoles;
RefPtr<VirtualConsole> m_active_console;
NonnullRefPtrVector<VirtualConsole, s_max_virtual_consoles> m_consoles;
VirtualConsole* m_active_console { nullptr };
SpinLock<u8> m_lock;
RecursiveSpinLock m_tty_write_lock;
};