1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:17: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:
Nico Weber 2020-09-09 19:06:57 -04:00 committed by Andreas Kling
parent 90d9c83067
commit 61060c0da8
2 changed files with 16 additions and 4 deletions

View file

@ -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);