From 89fcb01a58f23cdcc6bb0751f6f755d0f550dc2c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 9 Apr 2026 13:46:17 +0000 Subject: [PATCH] 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 --- src/Text/Pandoc/Shared.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index e1fb790f2..7ea690ef5 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -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