Commits

Bryan O'Sullivan committed 3629d6b

Use unsafeHead and unsafeTail for speed in a safe place

Comments (0)

Files changed (1)

 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.