on master help sign in
Tidy up lazy uncons

--HG-- extra : convert_revision : 82175828909534efe36cc79a8b225ea0a5104d05

commit3f6d768c7d28bae1e72120d8b33c3bea450e38b3 authorBryan O'Sullivan <bos@serpentine.com> dateSun 10 Oct 2010, 03:23 (16 years ago) parent156d940
1 file changed+4−4
Data/Text/Lazy.hs+4−4
Data/Text/Lazy.hs+4−4
@@ -332,10 +332,10 @@ append xs ys = foldrChunks Chunk ys xs
332332-- | /O(1)/ Returns the first character and rest of a 'Text', or
333333-- 'Nothing' if empty. Subject to array fusion.
334334uncons :: Text -> Maybe (Char, Text)
335−uncons Empty = Nothing
336−uncons (Chunk t ts) =
337− Just (T.unsafeHead t,
338− if T.compareLength t 1 == EQ then ts else Chunk (T.unsafeTail t) ts)
335+uncons Empty = Nothing
336+uncons (Chunk t ts) = Just (T.unsafeHead t, ts')
337+ where ts' | T.compareLength t 1 == EQ = ts
338+ | otherwise = Chunk (T.unsafeTail t) ts
339339{-# INLINE uncons #-}
340340
341341-- | /O(1)/ Returns the first character of a 'Text', which must be