mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +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:
parent
652fa54495
commit
2ff3c54153
2 changed files with 6 additions and 6 deletions
|
@ -29,7 +29,7 @@ bool ConsoleManagement::is_initialized()
|
|||
return false;
|
||||
if (s_the->m_consoles.is_empty())
|
||||
return false;
|
||||
if (s_the->m_active_console.is_null())
|
||||
if (s_the->m_active_console)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ UNMAP_AFTER_INIT void ConsoleManagement::initialize()
|
|||
if (tty_number > m_consoles.size()) {
|
||||
PANIC("Switch to tty value is invalid: {} ", tty_number);
|
||||
}
|
||||
m_active_console = m_consoles[tty_number];
|
||||
m_active_console = &m_consoles[tty_number];
|
||||
ScopedSpinLock lock(m_lock);
|
||||
m_active_console->set_active(true);
|
||||
if (!m_active_console->is_graphical())
|
||||
|
@ -75,7 +75,7 @@ void ConsoleManagement::switch_to(unsigned index)
|
|||
|
||||
bool was_graphical = m_active_console->is_graphical();
|
||||
m_active_console->set_active(false);
|
||||
m_active_console = m_consoles[index];
|
||||
m_active_console = &m_consoles[index];
|
||||
dbgln_if(VIRTUAL_CONSOLE_DEBUG, "Console: Switch to {}", index);
|
||||
|
||||
// Before setting current console to be "active", switch between graphical mode to "textual" mode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue