on master help sign in
Rename unsafeNew to new

--HG-- extra : convert_revision : 33cff1dbfc83ba3f819f1b67fb86c6d9648d2f9f

commit26eab0fd2fee218f38165758ce710574596fac1e authorBryan O'Sullivan <bos@serpentine.com> dateMon 4 Oct 2010, 02:31 (16 years ago) parenta156d4b
7 files changed+20−20
Data/Text.hs+3−3 Data/Text/Array.hs+5−5 Data/Text/Foreign.hs+1−1 Data/Text/Fusion.hs+6−6 Data/Text/Lazy/Builder.hs+2−2 Data/Text/Lazy/Fusion.hs+2−2 text.cabal+1−1
Data/Text.hs+3−3
@@ -344,7 +344,7 @@ append (Text arr1 off1 len1) (Text arr2 off2 len2) = Text (A.run x) 0 len
344344 where
345345 len = len1+len2
346346 x = do
347− arr <- A.unsafeNew len
347+ arr <- A.new len
348348 A.copyI arr 0 arr1 off1 len1
349349 A.copyI arr len1 arr2 off2 len
350350 return arr
@@ -708,7 +708,7 @@ concat ts = case ts' of
708708 ts' = L.filter (not . null) ts
709709 len = L.sum $ L.map lengthWord16 ts'
710710 go = do
711− arr <- A.unsafeNew len
711+ arr <- A.new len
712712 let step i (Text a o l) =
713713 let !j = i + l in A.copyI arr i a o j >> return j
714714 foldM step 0 ts' >> return arr
@@ -811,7 +811,7 @@ replicate n t@(Text a o l)
811811 where
812812 len = l * n
813813 x = do
814− arr <- A.unsafeNew len
814+ arr <- A.new len
815815 let loop !d !i | i >= n = return arr
816816 | otherwise = let m = d + l
817817 in A.copyI arr d a o m >> loop m (i+1)
Data/Text/Array.hs+5−5
@@ -41,7 +41,7 @@ module Data.Text.Array
4141 , toList
4242 , unsafeFreeze
4343 , unsafeIndex
44− , unsafeNew
44+ , new
4545 , unsafeWrite
4646 ) where
4747
@@ -101,8 +101,8 @@ instance IArray (MArray s) where
101101#endif
102102
103103-- | Create an uninitialized mutable array.
104−unsafeNew :: forall s. Int -> ST s (MArray s)
105−unsafeNew n
104+new :: forall s. Int -> ST s (MArray s)
105+new n
106106 | len < 0 = error $ "Data.Text.Array.unsafeNew: invalid length " ++ show n
107107 | otherwise = ST $ \s1# ->
108108 case newByteArray# len# s1# of
@@ -112,7 +112,7 @@ unsafeNew n
112112#endif
113113 #)
114114 where !len@(I# len#) = bytesInArray n
115−{-# INLINE unsafeNew #-}
115+{-# INLINE new #-}
116116
117117-- | Freeze a mutable array. Do not mutate the 'MArray' afterwards!
118118unsafeFreeze :: MArray s -> ST s Array
@@ -190,7 +190,7 @@ toList ary off len = loop 0
190190
191191-- | An empty immutable array.
192192empty :: Array
193−empty = runST (unsafeNew 0 >>= unsafeFreeze)
193+empty = runST (new 0 >>= unsafeFreeze)
194194
195195-- | Run an action in the ST monad and return an immutable array of
196196-- its result.
Data/Text/Foreign.hs+1−1
@@ -70,7 +70,7 @@ fromPtr ptr (I16 len) =
7070#endif
7171 return $! Text arr 0 len
7272 where
73− arr = A.run (A.unsafeNew len >>= copy)
73+ arr = A.run (A.new len >>= copy)
7474 copy marr = loop ptr 0
7575 where
7676 loop !p !i | i == len = return marr
Data/Text/Fusion.hs+6−6
@@ -96,7 +96,7 @@ reverseStream (Text arr off len) = Stream next (off+len-1) (maxSize len)
9696unstream :: Stream Char -> Text
9797unstream (Stream next0 s0 len) = I.textP (P.fst a) 0 (P.snd a)
9898 where
99− a = A.run2 (A.unsafeNew mlen >>= \arr -> outer arr mlen s0 0)
99+ a = A.run2 (A.new mlen >>= \arr -> outer arr mlen s0 0)
100100 where mlen = upperBound 4 len
101101 outer arr top = loop
102102 where
@@ -107,7 +107,7 @@ unstream (Stream next0 s0 len) = I.textP (P.fst a) 0 (P.snd a)
107107 Yield x s'
108108 | j >= top -> {-# SCC "unstream/resize" #-} do
109109 let top' = (top + 1) `shiftL` 1
110− arr' <- A.unsafeNew top'
110+ arr' <- A.new top'
111111 A.copyM arr' 0 arr 0 top
112112 outer arr' top' s i
113113 | otherwise -> do d <- unsafeWrite arr i x
@@ -132,7 +132,7 @@ reverse (Stream next s len0)
132132 | otherwise = I.textP arr off' len'
133133 where
134134 len0' = upperBound 4 (larger len0 4)
135− (arr, (off', len')) = A.run2 (A.unsafeNew len0' >>= loop s (len0'-1) len0')
135+ (arr, (off', len')) = A.run2 (A.new len0' >>= loop s (len0'-1) len0')
136136 loop !s0 !i !len marr =
137137 case next s0 of
138138 Done -> return (marr, (j, len-j))
@@ -140,7 +140,7 @@ reverse (Stream next s len0)
140140 Skip s1 -> loop s1 i len marr
141141 Yield x s1 | i < least -> {-# SCC "reverse/resize" #-} do
142142 let newLen = len `shiftL` 1
143− marr' <- A.unsafeNew newLen
143+ marr' <- A.new newLen
144144 A.copyM marr' (newLen-len) marr 0 len
145145 write s1 (len+i) newLen marr'
146146 | otherwise -> write s1 i len marr
@@ -209,7 +209,7 @@ countChar = S.countCharI
209209mapAccumL :: (a -> Char -> (a,Char)) -> a -> Stream Char -> (a, Text)
210210mapAccumL f z0 (Stream next0 s0 len) = (nz,I.textP na 0 nl)
211211 where
212− (na,(nz,nl)) = A.run2 (A.unsafeNew mlen >>= \arr -> outer arr mlen z0 s0 0)
212+ (na,(nz,nl)) = A.run2 (A.new mlen >>= \arr -> outer arr mlen z0 s0 0)
213213 where mlen = upperBound 4 len
214214 outer arr top = loop
215215 where
@@ -220,7 +220,7 @@ mapAccumL f z0 (Stream next0 s0 len) = (nz,I.textP na 0 nl)
220220 Yield x s'
221221 | j >= top -> {-# SCC "mapAccumL/resize" #-} do
222222 let top' = (top + 1) `shiftL` 1
223− arr' <- A.unsafeNew top'
223+ arr' <- A.new top'
224224 A.copyM arr' 0 arr 0 top
225225 outer arr' top' z s i
226226 | otherwise -> do let (z',c) = f z x
Data/Text/Lazy/Builder.hs+2−2
@@ -139,7 +139,7 @@ fromString str = Builder $ \k (Buffer p0 o0 u0 l0) ->
139139 | l <= 1 = do
140140 arr <- A.unsafeFreeze marr
141141 let !t = Text arr o u
142− marr' <- A.unsafeNew chunkSize
142+ marr' <- A.new chunkSize
143143 ts <- inlineInterleaveST (loop marr' 0 0 chunkSize s)
144144 return $ t : ts
145145 | otherwise = do
@@ -252,7 +252,7 @@ writeNBuffer n f (Buffer p o u l) = do
252252
253253newBuffer :: Int -> ST s (Buffer s)
254254newBuffer size = do
255− arr <- A.unsafeNew size
255+ arr <- A.new size
256256 return $! Buffer arr 0 0 size
257257{-# INLINE newBuffer #-}
258258
Data/Text/Lazy/Fusion.hs+2−2
@@ -59,14 +59,14 @@ unstreamChunks chunkSize (Stream next s0 len0)
5959 Skip s' -> outer s'
6060 Yield x s' -> I.Text arr 0 len `chunk` outer s''
6161 where (arr,(s'',len)) = A.run2 fill
62− fill = do a <- A.unsafeNew unknownLength
62+ fill = do a <- A.new unknownLength
6363 unsafeWrite a 0 x >>= inner a unknownLength s'
6464 unknownLength = 4
6565 inner marr len s !i
6666 | i + 1 >= chunkSize = return (marr, (s,i))
6767 | i + 1 >= len = do
6868 let newLen = min (len `shiftL` 1) chunkSize
69− marr' <- A.unsafeNew newLen
69+ marr' <- A.new newLen
7070 A.copyM marr' 0 marr 0 len
7171 inner marr' newLen s i
7272 | otherwise =
text.cabal+1−1
@@ -1,5 +1,5 @@
11name: text
2−version: 0.9.0.1
2+version: 0.9.0.2
33homepage: http://code.haskell.org/text
44synopsis: An efficient packed Unicode text type.
55description: