mirror of https://github.com/Textualize/rich.git
optimization for Segment.divid
This commit is contained in:
parent
4dec7980fe
commit
bb8a384d87
|
@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Changed
|
||||
|
||||
- Setting `total=None` on progress is now possible, and will display pulsing animation
|
||||
- Micro-optimization for Segment.divide
|
||||
|
||||
## [12.2.0] - 2022-04-05
|
||||
|
||||
|
|
|
@ -611,9 +611,14 @@ class Segment(NamedTuple):
|
|||
yield []
|
||||
pos = 0
|
||||
|
||||
_cell_len = cell_len
|
||||
for segment in segments:
|
||||
while segment.text:
|
||||
end_pos = pos + segment.cell_length
|
||||
text, _style, control = segment
|
||||
while text:
|
||||
if control:
|
||||
end_pos = pos
|
||||
else:
|
||||
end_pos = pos + _cell_len(text)
|
||||
if end_pos < cut:
|
||||
add_segment(segment)
|
||||
pos = end_pos
|
||||
|
@ -628,6 +633,7 @@ class Segment(NamedTuple):
|
|||
break
|
||||
else:
|
||||
before, segment = segment.split_cells(cut - pos)
|
||||
text, _style, control = segment
|
||||
add_segment(before)
|
||||
yield split_segments[:]
|
||||
del split_segments[:]
|
||||
|
|
Loading…
Reference in New Issue