From ec1486c4ba18452da4a5948477c1f8fe02c46d8f Mon Sep 17 00:00:00 2001 From: Nicole Rauch Date: Sun, 14 Aug 2016 19:35:43 +0200 Subject: Compacted the code by unifying all the similar prefix options. --- src/Hakyll/Web/CompressCss.hs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Hakyll/Web/CompressCss.hs b/src/Hakyll/Web/CompressCss.hs index c00b5ee..aac48b1 100644 --- a/src/Hakyll/Web/CompressCss.hs +++ b/src/Hakyll/Web/CompressCss.hs @@ -37,17 +37,14 @@ compressSeparators [] = [] compressSeparators str | isPrefixOf "\"" str = head str : retainConstants compressSeparators "\"" (drop 1 str) | isPrefixOf "'" str = head str : retainConstants compressSeparators "'" (drop 1 str) - | isPrefixOf " " str = compressSeparators (drop 1 str) - | isPrefixOf " {" str = compressSeparators (drop 1 str) - | isPrefixOf " }" str = compressSeparators (drop 1 str) - | isPrefixOf " ;" str = compressSeparators (drop 1 str) - | isPrefixOf ";;" str = compressSeparators (drop 1 str) - | isPrefixOf "{ " str = compressSeparators (head str : (drop 2 str)) - | isPrefixOf "} " str = compressSeparators (head str : (drop 2 str)) - | isPrefixOf "; " str = compressSeparators (head str : (drop 2 str)) + | stripFirst = compressSeparators (drop 1 str) + | stripSecond = compressSeparators (head str : (drop 2 str)) | isPrefixOf ";}" str = '}' : compressSeparators (drop 2 str) | otherwise = head str : compressSeparators (drop 1 str) - + where + prefix p = isPrefixOf p str + stripFirst = or $ map prefix [" ", " {", " }", ";;"] + stripSecond = or $ map prefix ["{ ", "} ", "; "] -------------------------------------------------------------------------------- -- | Compresses all whitespace. -- cgit v1.2.3