Commits

Bryan O'Sullivan committed 61038db

Rename unsafeNew to new

Comments (0)

Files changed (7)

     where
       len = len1+len2
       x = do
-        arr <- A.unsafeNew len
+        arr <- A.new len
         A.copyI arr 0 arr1 off1 len1
         A.copyI arr len1 arr2 off2 len
         return arr
     ts' = L.filter (not . null) ts
     len = L.sum $ L.map lengthWord16 ts'
     go = do
-      arr <- A.unsafeNew len
+      arr <- A.new len
       let step i (Text a o l) =
             let !j = i + l in A.copyI arr i a o j >> return j
       foldM step 0 ts' >> return arr
   where
     len = l * n
     x = do
-      arr <- A.unsafeNew len
+      arr <- A.new len
       let loop !d !i | i >= n    = return arr
                      | otherwise = let m = d + l
                                    in A.copyI arr d a o m >> loop m (i+1)

Data/Text/Array.hs

     , toList
     , unsafeFreeze
     , unsafeIndex
-    , unsafeNew
+    , new
     , unsafeWrite
     ) where
 
 #endif
 
 -- | Create an uninitialized mutable array.
-unsafeNew :: forall s. Int -> ST s (MArray s)
-unsafeNew n
+new :: forall s. Int -> ST s (MArray s)
+new n
   | len < 0 = error $ "Data.Text.Array.unsafeNew: invalid length " ++ show n
   | otherwise = ST $ \s1# ->
        case newByteArray# len# s1# of
 #endif
                                 #)
   where !len@(I# len#) = bytesInArray n
-{-# INLINE unsafeNew #-}
+{-# INLINE new #-}
 
 -- | Freeze a mutable array. Do not mutate the 'MArray' afterwards!
 unsafeFreeze :: MArray s -> ST s Array
 
 -- | An empty immutable array.
 empty :: Array
-empty = runST (unsafeNew 0 >>= unsafeFreeze)
+empty = runST (new 0 >>= unsafeFreeze)
 
 -- | Run an action in the ST monad and return an immutable array of
 -- its result.

Data/Text/Foreign.hs

 #endif
     return $! Text arr 0 len
   where
-    arr = A.run (A.unsafeNew len >>= copy)
+    arr = A.run (A.new len >>= copy)
     copy marr = loop ptr 0
       where
         loop !p !i | i == len = return marr

Data/Text/Fusion.hs

 unstream :: Stream Char -> Text
 unstream (Stream next0 s0 len) = I.textP (P.fst a) 0 (P.snd a)
   where
-    a = A.run2 (A.unsafeNew mlen >>= \arr -> outer arr mlen s0 0)
+    a = A.run2 (A.new mlen >>= \arr -> outer arr mlen s0 0)
       where mlen = upperBound 4 len
     outer arr top = loop
       where
               Yield x s'
                 | j >= top  -> {-# SCC "unstream/resize" #-} do
                                let top' = (top + 1) `shiftL` 1
-                               arr' <- A.unsafeNew top'
+                               arr' <- A.new top'
                                A.copyM arr' 0 arr 0 top
                                outer arr' top' s i
                 | otherwise -> do d <- unsafeWrite arr i x
     | otherwise    = I.textP arr off' len'
   where
     len0' = upperBound 4 (larger len0 4)
-    (arr, (off', len')) = A.run2 (A.unsafeNew len0' >>= loop s (len0'-1) len0')
+    (arr, (off', len')) = A.run2 (A.new len0' >>= loop s (len0'-1) len0')
     loop !s0 !i !len marr =
         case next s0 of
           Done -> return (marr, (j, len-j))
           Skip s1    -> loop s1 i len marr
           Yield x s1 | i < least -> {-# SCC "reverse/resize" #-} do
                        let newLen = len `shiftL` 1
-                       marr' <- A.unsafeNew newLen
+                       marr' <- A.new newLen
                        A.copyM marr' (newLen-len) marr 0 len
                        write s1 (len+i) newLen marr'
                      | otherwise -> write s1 i len marr
 mapAccumL :: (a -> Char -> (a,Char)) -> a -> Stream Char -> (a, Text)
 mapAccumL f z0 (Stream next0 s0 len) = (nz,I.textP na 0 nl)
   where
-    (na,(nz,nl)) = A.run2 (A.unsafeNew mlen >>= \arr -> outer arr mlen z0 s0 0)
+    (na,(nz,nl)) = A.run2 (A.new mlen >>= \arr -> outer arr mlen z0 s0 0)
       where mlen = upperBound 4 len
     outer arr top = loop
       where
               Yield x s'
                 | j >= top  -> {-# SCC "mapAccumL/resize" #-} do
                                let top' = (top + 1) `shiftL` 1
-                               arr' <- A.unsafeNew top'
+                               arr' <- A.new top'
                                A.copyM arr' 0 arr 0 top
                                outer arr' top' z s i
                 | otherwise -> do let (z',c) = f z x

Data/Text/Lazy/Builder.hs

             | l <= 1 = do
                 arr <- A.unsafeFreeze marr
                 let !t = Text arr o u
-                marr' <- A.unsafeNew chunkSize
+                marr' <- A.new chunkSize
                 ts <- inlineInterleaveST (loop marr' 0 0 chunkSize s)
                 return $ t : ts
             | otherwise = do
 
 newBuffer :: Int -> ST s (Buffer s)
 newBuffer size = do
-    arr <- A.unsafeNew size
+    arr <- A.new size
     return $! Buffer arr 0 0 size
 {-# INLINE newBuffer #-}
 

Data/Text/Lazy/Fusion.hs

                 Skip s'    -> outer s'
                 Yield x s' -> I.Text arr 0 len `chunk` outer s''
                   where (arr,(s'',len)) = A.run2 fill
-                        fill = do a <- A.unsafeNew unknownLength
+                        fill = do a <- A.new unknownLength
                                   unsafeWrite a 0 x >>= inner a unknownLength s'
                         unknownLength = 4
     inner marr len s !i
         | i + 1 >= chunkSize = return (marr, (s,i))
         | i + 1 >= len       = do
             let newLen = min (len `shiftL` 1) chunkSize
-            marr' <- A.unsafeNew newLen
+            marr' <- A.new newLen
             A.copyM marr' 0 marr 0 len
             inner marr' newLen s i
         | otherwise =
 name:           text
-version:        0.9.0.1
+version:        0.9.0.2
 homepage:       http://code.haskell.org/text
 synopsis:       An efficient packed Unicode text type.
 description:    
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.