Skip to content

Commit

Permalink
Merge pull request #1810 from Textualize/datatable-cache-fix-performa…
Browse files Browse the repository at this point in the history
…nce-improvement

DataTable - Actually use the offset cache.
  • Loading branch information
willmcgugan authored Feb 16, 2023
2 parents 29bf387 + a78563c commit ba6c8af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

- DataTable fix issue where offset cache was not being used https://github.com/Textualize/textual/pull/1810
- DataTable scrollbars resize correctly when header is toggled https://github.com/Textualize/textual/pull/1803
- DataTable location mapping cleared when clear called https://github.com/Textualize/textual/pull/1809

Expand Down
3 changes: 2 additions & 1 deletion src/textual/widgets/_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def _y_offsets(self) -> list[tuple[RowKey, int]]:
else:
for row in self.ordered_rows:
y_offsets += [(row.key, y) for y in range(row.height)]
self._offset_cache = y_offsets
self._offset_cache[self._update_count] = y_offsets
return y_offsets

@property
Expand Down Expand Up @@ -1119,6 +1119,7 @@ def add_row(
if cell_now_available and visible_cursor:
self._highlight_cursor()

self._update_count += 1
self.check_idle()
return row_key

Expand Down

0 comments on commit ba6c8af

Please sign in to comment.