on master help sign in
Tidy up lazy uncons
3f6d768Bryan O'Sullivan
Data/Text/Lazy.hs+4−4
@@ -332,10 +332,10 @@ append xs ys = foldrChunks Chunk ys xs
332-- | /O(1)/ Returns the first character and rest of a 'Text', or
332-- | /O(1)/ Returns the first character and rest of a 'Text', or
333-- 'Nothing' if empty. Subject to array fusion.
333-- 'Nothing' if empty. Subject to array fusion.
334uncons :: Text -> Maybe (Char, Text)
334uncons :: Text -> Maybe (Char, Text)
335−uncons Empty = Nothing
335+uncons Empty = Nothing
336−uncons (Chunk t ts) =
337− Just (T.unsafeHead t,
336+uncons (Chunk t ts) = Just (T.unsafeHead t, ts')
338− if T.compareLength t 1 == EQ then ts else Chunk (T.unsafeTail t) ts)
337+ where ts' | T.compareLength t 1 == EQ = ts
338+ | otherwise = Chunk (T.unsafeTail t) ts
339{-# INLINE uncons #-}
339{-# INLINE uncons #-}
340
340
341-- | /O(1)/ Returns the first character of a 'Text', which must be
341-- | /O(1)/ Returns the first character of a 'Text', which must be