Skip to content

Commit 3da22fc

Browse files
committed
Improve code
1 parent a43d1ff commit 3da22fc

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main/python/ttconv/scc/writer.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,14 @@ def _isd_progress(progress: float):
259259
if len(captions) > 0 and captions[-1].get_end() is None:
260260
captions[-1].set_end(begin)
261261

262-
non_empty_region_cnt = sum((1 for r in isd.iter_regions() if len(r) > 0), 0)
262+
non_empty_region_cnt = 0
263+
for r in isd.iter_regions():
264+
if len(r) > 0:
265+
non_empty_region_cnt += 1
266+
if non_empty_region_cnt > 1:
267+
# SCC can only handle one region at a time
268+
LOGGER.warning("Merging multiple regions at %ss; errors may result", float(begin))
269+
break
263270

264271
if non_empty_region_cnt == 0:
265272
# skip empty ISD
@@ -268,10 +275,6 @@ def _isd_progress(progress: float):
268275

269276
is_last_empty = False
270277

271-
# SCC can only handle one region at a time
272-
if non_empty_region_cnt > 1:
273-
LOGGER.warning("Merging multiple regions at %ss; errors may result", float(begin))
274-
275278
caption: _Caption = _Caption.from_regions(list(isd.iter_regions()))
276279
caption.set_begin(begin)
277280

0 commit comments

Comments
 (0)