on master help sign in
Fix bad performance of Data.Text.Lazy.uncons

--HG-- extra : convert_revision : 252a3b725bc25d48b54ea5e27006db92b648a5ce

commit156d940eaf81ef185eee59dc3952c93a458b8fc5 authorBryan O'Sullivan <bos@serpentine.com> dateSun 10 Oct 2010, 02:57 (16 years ago) parente3fdf7e
1 file changed+2−2
Data/Text/Lazy.hs+2−2
Data/Text/Lazy.hs+2−2
@@ -174,7 +174,7 @@ module Data.Text.Lazy
174174 ) where
175175
176176import Prelude (Char, Bool(..), Maybe(..), String,
177− Eq(..), Ord(..), Ordering, Read(..), Show(..),
177+ Eq(..), Ord(..), Ordering(..), Read(..), Show(..),
178178 (&&), (+), (-), (.), ($), (++),
179179 div, error, flip, fromIntegral, not, otherwise)
180180import qualified Prelude as P
@@ -335,7 +335,7 @@ uncons :: Text -> Maybe (Char, Text)
335335uncons Empty = Nothing
336336uncons (Chunk t ts) =
337337 Just (T.unsafeHead t,
338− if T.length t == 1 then ts else Chunk (T.unsafeTail t) ts)
338+ if T.compareLength t 1 == EQ then ts else Chunk (T.unsafeTail t) ts)
339339{-# INLINE uncons #-}
340340
341341-- | /O(1)/ Returns the first character of a 'Text', which must be