Skip to content

Commit bb9ebdb

Browse files
committed
micro optimizations
1 parent f76670e commit bb9ebdb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/textual/layouts/stream.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class StreamLayout(Layout):
2121
- No absolute positioning.
2222
- No overlay: screen.
2323
- Layers are ignored.
24+
- Non TCSS styles are ignored.
2425
2526
The primary use of `layout: stream` is for a long list of widgets in a scrolling container, such as
2627
what you might expect from a LLM chat-bot. The speed improvement will only be significant with a lot of
@@ -49,18 +50,22 @@ def arrange(
4950
null_offset = NULL_OFFSET
5051

5152
for widget in children:
52-
styles = widget.styles.base
53+
styles = widget.styles._base_styles
5354
margin = styles.margin
5455
gutter_width, gutter_height = styles.gutter.totals
5556
top, right, bottom, left = margin
56-
y += max(top, previous_margin)
57+
y += top if top > previous_margin else previous_margin
5758
previous_margin = bottom
5859
height = (
5960
widget.get_content_height(size, viewport, width - gutter_width)
6061
+ gutter_height
6162
)
6263
if (max_height := styles.max_height) is not None and max_height.is_cells:
63-
height = min(height, int(max_height.value))
64+
height = (
65+
height
66+
if height < (max_height_value := int(max_height.value))
67+
else max_height_value
68+
)
6469
placements.append(
6570
_WidgetPlacement(
6671
_Region(left, y, width - (left + right), height),

0 commit comments

Comments
 (0)