Skip to content

Commit 021c8d8

Browse files
committed
Avoid construction of a list
1 parent a7438f6 commit 021c8d8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

curtsies/formatstringarray.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,16 @@ def fsarray(
268268
raise ValueError(f"Those strings won't fit for width {width}")
269269
else:
270270
width = max(len(s) for s in strings) if strings else 0
271-
fstrings = [
272-
s if isinstance(s, FmtStr) else fmtstr(s, *args, **kwargs) for s in strings
273-
]
274-
arr = FSArray(len(fstrings), width, *args, **kwargs)
271+
arr = FSArray(len(strings), width, *args, **kwargs)
275272
rows = [
276273
fs.setslice_with_length(0, len(s), s, width)
277-
for fs, s in zip(arr.rows, fstrings)
274+
for fs, s in zip(
275+
arr.rows,
276+
(
277+
s if isinstance(s, FmtStr) else fmtstr(s, *args, **kwargs)
278+
for s in strings
279+
),
280+
)
278281
]
279282
arr.rows = rows
280283
return arr

0 commit comments

Comments
 (0)