BufferView optimization: avoid calling calculate_rows_in_cursor_line() twice per update()
This commit is contained in:
parent
359f5bed9f
commit
f3604e1850
@ -36,6 +36,12 @@ BufferView::Iterator BufferView::vert_iter()
|
|||||||
|
|
||||||
void BufferView::update()
|
void BufferView::update()
|
||||||
{
|
{
|
||||||
|
/* Calculate number of rows in the cursor line and update cursor row offset
|
||||||
|
* and cursor column values. */
|
||||||
|
auto start_of_line = std::make_shared<Buffer::Iterator>(*m_iterator);
|
||||||
|
start_of_line->go_start_of_line();
|
||||||
|
int rows_in_cursor_line = calculate_rows_in_cursor_line(start_of_line);
|
||||||
|
|
||||||
/* Update the cursor screen row in case the cursor position changed. */
|
/* Update the cursor screen row in case the cursor position changed. */
|
||||||
m_cursor_screen_row = determine_new_cursor_screen_row();
|
m_cursor_screen_row = determine_new_cursor_screen_row();
|
||||||
|
|
||||||
@ -43,9 +49,6 @@ void BufferView::update()
|
|||||||
* available buffer contents above and below the current line, and scroll
|
* available buffer contents above and below the current line, and scroll
|
||||||
* offset. */
|
* offset. */
|
||||||
std::list<std::pair<int, std::shared_ptr<Buffer::Iterator>>> backward_lines;
|
std::list<std::pair<int, std::shared_ptr<Buffer::Iterator>>> backward_lines;
|
||||||
auto start_of_line = std::make_shared<Buffer::Iterator>(*m_iterator);
|
|
||||||
start_of_line->go_start_of_line();
|
|
||||||
int rows_in_cursor_line = calculate_rows_in_cursor_line(start_of_line);
|
|
||||||
int so = effective_scroll_offset();
|
int so = effective_scroll_offset();
|
||||||
int rows_above = screen_rows_above_line(start_of_line, backward_lines) + m_cursor_row_offset;
|
int rows_above = screen_rows_above_line(start_of_line, backward_lines) + m_cursor_row_offset;
|
||||||
int rows_below = screen_rows_below_line(start_of_line) + std::max(0, rows_in_cursor_line - m_cursor_row_offset - 1);
|
int rows_below = screen_rows_below_line(start_of_line) + std::max(0, rows_in_cursor_line - m_cursor_row_offset - 1);
|
||||||
@ -115,7 +118,6 @@ int BufferView::determine_new_cursor_screen_row()
|
|||||||
{
|
{
|
||||||
if (screen_line.line->line() == m_iterator->line())
|
if (screen_line.line->line() == m_iterator->line())
|
||||||
{
|
{
|
||||||
calculate_rows_in_cursor_line(screen_line.line);
|
|
||||||
return screen_line.row_offset + m_cursor_row_offset;
|
return screen_line.row_offset + m_cursor_row_offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user