git.iko.soy/typeable/pandoc
on master help sign in
Slightly more efficient normalizeSpaces.
commit02ef26ae91f7c1db1e4018c69b33f59c3ce837a2 authorJohn MacFarlane <fiddlosopher@gmail.com> dateTue 24 Jul 2012, 22:12 (14 years ago) parentc00f5c4
1 file changed+5−6
src/Text/Pandoc/Shared.hs+5−6
src/Text/Pandoc/Shared.hs+5−6
@@ -272,13 +272,12 @@ orderedListMarkers (start, numstyle, numdelim) =
272272-- remove empty Str elements.
273273normalizeSpaces :: [Inline] -> [Inline]
274274normalizeSpaces = cleanup . dropWhile isSpaceOrEmpty
275− where cleanup [] = []
276− cleanup (Space:rest) = let rest' = dropWhile isSpaceOrEmpty rest
277− in case rest' of
278− [] -> []
279− _ -> Space : cleanup rest'
275+ where cleanup [] = []
276+ cleanup (Space:rest) = case dropWhile isSpaceOrEmpty rest of
277+ [] -> []
278+ (x:xs) -> Space : x : cleanup xs
280279 cleanup ((Str ""):rest) = cleanup rest
281− cleanup (x:rest) = x : cleanup rest
280+ cleanup (x:rest) = x : cleanup rest
282281
283282isSpaceOrEmpty :: Inline -> Bool
284283isSpaceOrEmpty Space = True