Shared: use short-circuiting 'any' in compactify

Replace list comprehension filters (which materialize the full
list) with 'any isPara', allowing early exit on the first match.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
John MacFarlane
2026-04-09 13:46:17 +00:00
co-authored by Claude
parent 8b17e1c66d
commit 89fcb01a58
+2 -2
View File
@@ -412,9 +412,9 @@ compactify items =
let (others, final) = (init items, last items)
in case reverse (B.toList final) of
(Para a:xs)
| null [Para x | Para x <- xs ++ concatMap B.toList others]
| not (any isPara xs || any (any isPara . B.toList) others)
-> others ++ [B.fromList (reverse (Plain a : xs))]
_ | null [Para x | Para x <- concatMap B.toList items]
_ | not (any (any isPara . B.toList) items)
-> items
_ -> map (fmap plainToPara) items