mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
LibVT: Let Terminal keep history in a circular buffer
This makes Terminal::scroll_up() O(1) instead of O(n) in the size of the history. (It's still O(n) in the size of visible lines.) Reduces time to run `disasm /bin/id` with the default terminal window size from 530ms to 409ms (min-of-5) on my system.
This commit is contained in:
parent
90d9c83067
commit
61060c0da8
2 changed files with 16 additions and 4 deletions
|
@ -52,6 +52,8 @@ void Terminal::clear()
|
|||
void Terminal::clear_including_history()
|
||||
{
|
||||
m_history.clear();
|
||||
m_history_start = 0;
|
||||
|
||||
clear();
|
||||
|
||||
m_client.terminal_history_changed();
|
||||
|
@ -738,9 +740,7 @@ void Terminal::scroll_up()
|
|||
invalidate_cursor();
|
||||
if (m_scroll_region_top == 0) {
|
||||
auto line = move(m_lines.ptr_at(m_scroll_region_top));
|
||||
m_history.append(move(line));
|
||||
while (m_history.size() > max_history_size())
|
||||
m_history.take_first();
|
||||
add_line_to_history(move(line));
|
||||
m_client.terminal_history_changed();
|
||||
}
|
||||
m_lines.remove(m_scroll_region_top);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue