Commits

Bryan O'Sullivan committed 3629d6b

Use unsafeHead and unsafeTail for speed in a safe place

  • Participants
  • Parent commits 079b4b3

Comments (0)

Files changed (1)

File Data/Text.hs

 import Data.Text.Fusion (Stream(..), Step(..), stream, unstream)
 import Data.Text.Internal (Text(..), empty, text)
 import qualified Prelude as P
-import Data.Text.Unsafe (iter, iter_)
+import Data.Text.Unsafe (iter, iter_, unsafeHead, unsafeTail)
 import Data.Text.UnsafeChar (unsafeChr)
 import qualified Data.Text.Utf16 as U16
 
 -- > scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
 scanl1 :: (Char -> Char -> Char) -> Text -> Text
 scanl1 f t | null t    = empty
-           | otherwise = scanl f (head t) (tail t)
+           | otherwise = scanl f (unsafeHead t) (unsafeTail t)
 {-# INLINE scanl1 #-}
 
 -- | /O(n)/ Like a combination of 'map' and 'foldl'. Applies a