mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
optimization
This commit is contained in:
@@ -276,7 +276,10 @@ class Compositor:
|
||||
resized_widgets = {
|
||||
widget
|
||||
for widget, (region, *_) in changes
|
||||
if widget in common_widgets and old_map[widget].region.size != region.size
|
||||
if (
|
||||
widget in common_widgets
|
||||
and not old_map[widget].region.same_size(region)
|
||||
)
|
||||
}
|
||||
|
||||
screen_region = size.region
|
||||
|
||||
@@ -541,6 +541,18 @@ class Region(NamedTuple):
|
||||
width2, height2 = size
|
||||
return Region(x, y, min(width1, width2), min(height1, height2))
|
||||
|
||||
def same_size(self, region: Region) -> bool:
|
||||
"""Check if another region is the same size. Equivalent to `self.size == region.size`,
|
||||
but a little faster.
|
||||
|
||||
Args:
|
||||
region (Region): A region.
|
||||
|
||||
Returns:
|
||||
bool: True if both regions are the same size, False if they are different sizes.
|
||||
"""
|
||||
return self[2:] == region[2:]
|
||||
|
||||
def expand(self, size: tuple[int, int]) -> Region:
|
||||
"""Increase the size of the region by adding a border.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user