mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:18:11 +00:00
Spreadsheet: Improve sheet update efficiency
There's no need to leave the cell dirty when not updating it, and there's definitely no need to update the cells as we're selecting them. This makes navigating a sheet and selecting cells significantly faster as we no longer update unrelated cells just because they appear to have a cyclic update dependency :^)
This commit is contained in:
parent
bfb25855cb
commit
8f05e4e765
5 changed files with 35 additions and 6 deletions
|
@ -154,12 +154,18 @@ String Sheet::add_column()
|
|||
|
||||
void Sheet::update()
|
||||
{
|
||||
if (m_should_ignore_updates) {
|
||||
m_update_requested = true;
|
||||
return;
|
||||
}
|
||||
m_visited_cells_in_update.clear();
|
||||
Vector<Cell*> cells_copy;
|
||||
|
||||
// Grab a copy as updates might insert cells into the table.
|
||||
for (auto& it : m_cells)
|
||||
cells_copy.append(it.value);
|
||||
for (auto& it : m_cells) {
|
||||
if (it.value->dirty())
|
||||
cells_copy.append(it.value);
|
||||
}
|
||||
|
||||
for (auto& cell : cells_copy)
|
||||
update(*cell);
|
||||
|
@ -169,10 +175,15 @@ void Sheet::update()
|
|||
|
||||
void Sheet::update(Cell& cell)
|
||||
{
|
||||
if (m_should_ignore_updates) {
|
||||
m_update_requested = true;
|
||||
return;
|
||||
}
|
||||
if (cell.dirty()) {
|
||||
if (has_been_visited(&cell)) {
|
||||
// This may be part of an cyclic reference chain
|
||||
// just break the chain, but leave the cell dirty.
|
||||
// This may be part of an cyclic reference chain,
|
||||
// so just ignore it.
|
||||
cell.clear_dirty();
|
||||
return;
|
||||
}
|
||||
m_visited_cells_in_update.set(&cell);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue