on master help sign in
Rename unsafeNew to new
26eab0fBryan O'Sullivan
Data/Text.hs+3−3
@@ -344,7 +344,7 @@ append (Text arr1 off1 len1) (Text arr2 off2 len2) = Text (A.run x) 0 len
344 where
344 where
345 len = len1+len2
345 len = len1+len2
346 x = do
346 x = do
347− arr <- A.unsafeNew len
347+ arr <- A.new len
348 A.copyI arr 0 arr1 off1 len1
348 A.copyI arr 0 arr1 off1 len1
349 A.copyI arr len1 arr2 off2 len
349 A.copyI arr len1 arr2 off2 len
350 return arr
350 return arr
@@ -708,7 +708,7 @@ concat ts = case ts' of
708 ts' = L.filter (not . null) ts
708 ts' = L.filter (not . null) ts
709 len = L.sum $ L.map lengthWord16 ts'
709 len = L.sum $ L.map lengthWord16 ts'
710 go = do
710 go = do
711− arr <- A.unsafeNew len
711+ arr <- A.new len
712 let step i (Text a o l) =
712 let step i (Text a o l) =
713 let !j = i + l in A.copyI arr i a o j >> return j
713 let !j = i + l in A.copyI arr i a o j >> return j
714 foldM step 0 ts' >> return arr
714 foldM step 0 ts' >> return arr
@@ -811,7 +811,7 @@ replicate n t@(Text a o l)
811 where
811 where
812 len = l * n
812 len = l * n
813 x = do
813 x = do
814− arr <- A.unsafeNew len
814+ arr <- A.new len
815 let loop !d !i | i >= n = return arr
815 let loop !d !i | i >= n = return arr
816 | otherwise = let m = d + l
816 | otherwise = let m = d + l
817 in A.copyI arr d a o m >> loop m (i+1)
817 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
41 , toList
41 , toList
42 , unsafeFreeze
42 , unsafeFreeze
43 , unsafeIndex
43 , unsafeIndex
44− , unsafeNew
44+ , new
45 , unsafeWrite
45 , unsafeWrite
46 ) where
46 ) where
47
47
@@ -101,8 +101,8 @@ instance IArray (MArray s) where
101#endif
101#endif
102
102
103-- | Create an uninitialized mutable array.
103-- | Create an uninitialized mutable array.
104−unsafeNew :: forall s. Int -> ST s (MArray s)
104+new :: forall s. Int -> ST s (MArray s)
105−unsafeNew n
105+new n
106 | len < 0 = error $ "Data.Text.Array.unsafeNew: invalid length " ++ show n
106 | len < 0 = error $ "Data.Text.Array.unsafeNew: invalid length " ++ show n
107 | otherwise = ST $ \s1# ->
107 | otherwise = ST $ \s1# ->
108 case newByteArray# len# s1# of
108 case newByteArray# len# s1# of
@@ -112,7 +112,7 @@ unsafeNew n
112#endif
112#endif
113 #)
113 #)
114 where !len@(I# len#) = bytesInArray n
114 where !len@(I# len#) = bytesInArray n
115−{-# INLINE unsafeNew #-}
115+{-# INLINE new #-}
116
116
117-- | Freeze a mutable array. Do not mutate the 'MArray' afterwards!
117-- | Freeze a mutable array. Do not mutate the 'MArray' afterwards!
118unsafeFreeze :: MArray s -> ST s Array
118unsafeFreeze :: MArray s -> ST s Array
@@ -190,7 +190,7 @@ toList ary off len = loop 0
190
190
191-- | An empty immutable array.
191-- | An empty immutable array.
192empty :: Array
192empty :: Array
193−empty = runST (unsafeNew 0 >>= unsafeFreeze)
193+empty = runST (new 0 >>= unsafeFreeze)
194
194
195-- | Run an action in the ST monad and return an immutable array of
195-- | Run an action in the ST monad and return an immutable array of
196-- its result.
196-- its result.
Data/Text/Foreign.hs+1−1
@@ -70,7 +70,7 @@ fromPtr ptr (I16 len) =
70#endif
70#endif
71 return $! Text arr 0 len
71 return $! Text arr 0 len
72 where
72 where
73− arr = A.run (A.unsafeNew len >>= copy)
73+ arr = A.run (A.new len >>= copy)
74 copy marr = loop ptr 0
74 copy marr = loop ptr 0
75 where
75 where
76 loop !p !i | i == len = return marr
76 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)
96unstream :: Stream Char -> Text
96unstream :: Stream Char -> Text
97unstream (Stream next0 s0 len) = I.textP (P.fst a) 0 (P.snd a)
97unstream (Stream next0 s0 len) = I.textP (P.fst a) 0 (P.snd a)
98 where
98 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)
100 where mlen = upperBound 4 len
100 where mlen = upperBound 4 len
101 outer arr top = loop
101 outer arr top = loop
102 where
102 where
@@ -107,7 +107,7 @@ unstream (Stream next0 s0 len) = I.textP (P.fst a) 0 (P.snd a)
107 Yield x s'
107 Yield x s'
108 | j >= top -> {-# SCC "unstream/resize" #-} do
108 | j >= top -> {-# SCC "unstream/resize" #-} do
109 let top' = (top + 1) `shiftL` 1
109 let top' = (top + 1) `shiftL` 1
110− arr' <- A.unsafeNew top'
110+ arr' <- A.new top'
111 A.copyM arr' 0 arr 0 top
111 A.copyM arr' 0 arr 0 top
112 outer arr' top' s i
112 outer arr' top' s i
113 | otherwise -> do d <- unsafeWrite arr i x
113 | otherwise -> do d <- unsafeWrite arr i x
@@ -132,7 +132,7 @@ reverse (Stream next s len0)
132 | otherwise = I.textP arr off' len'
132 | otherwise = I.textP arr off' len'
133 where
133 where
134 len0' = upperBound 4 (larger len0 4)
134 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')
136 loop !s0 !i !len marr =
136 loop !s0 !i !len marr =
137 case next s0 of
137 case next s0 of
138 Done -> return (marr, (j, len-j))
138 Done -> return (marr, (j, len-j))
@@ -140,7 +140,7 @@ reverse (Stream next s len0)
140 Skip s1 -> loop s1 i len marr
140 Skip s1 -> loop s1 i len marr
141 Yield x s1 | i < least -> {-# SCC "reverse/resize" #-} do
141 Yield x s1 | i < least -> {-# SCC "reverse/resize" #-} do
142 let newLen = len `shiftL` 1
142 let newLen = len `shiftL` 1
143− marr' <- A.unsafeNew newLen
143+ marr' <- A.new newLen
144 A.copyM marr' (newLen-len) marr 0 len
144 A.copyM marr' (newLen-len) marr 0 len
145 write s1 (len+i) newLen marr'
145 write s1 (len+i) newLen marr'
146 | otherwise -> write s1 i len marr
146 | otherwise -> write s1 i len marr
@@ -209,7 +209,7 @@ countChar = S.countCharI
209mapAccumL :: (a -> Char -> (a,Char)) -> a -> Stream Char -> (a, Text)
209mapAccumL :: (a -> Char -> (a,Char)) -> a -> Stream Char -> (a, Text)
210mapAccumL f z0 (Stream next0 s0 len) = (nz,I.textP na 0 nl)
210mapAccumL f z0 (Stream next0 s0 len) = (nz,I.textP na 0 nl)
211 where
211 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)
213 where mlen = upperBound 4 len
213 where mlen = upperBound 4 len
214 outer arr top = loop
214 outer arr top = loop
215 where
215 where
@@ -220,7 +220,7 @@ mapAccumL f z0 (Stream next0 s0 len) = (nz,I.textP na 0 nl)
220 Yield x s'
220 Yield x s'
221 | j >= top -> {-# SCC "mapAccumL/resize" #-} do
221 | j >= top -> {-# SCC "mapAccumL/resize" #-} do
222 let top' = (top + 1) `shiftL` 1
222 let top' = (top + 1) `shiftL` 1
223− arr' <- A.unsafeNew top'
223+ arr' <- A.new top'
224 A.copyM arr' 0 arr 0 top
224 A.copyM arr' 0 arr 0 top
225 outer arr' top' z s i
225 outer arr' top' z s i
226 | otherwise -> do let (z',c) = f z x
226 | 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) ->
139 | l <= 1 = do
139 | l <= 1 = do
140 arr <- A.unsafeFreeze marr
140 arr <- A.unsafeFreeze marr
141 let !t = Text arr o u
141 let !t = Text arr o u
142− marr' <- A.unsafeNew chunkSize
142+ marr' <- A.new chunkSize
143 ts <- inlineInterleaveST (loop marr' 0 0 chunkSize s)
143 ts <- inlineInterleaveST (loop marr' 0 0 chunkSize s)
144 return $ t : ts
144 return $ t : ts
145 | otherwise = do
145 | otherwise = do
@@ -252,7 +252,7 @@ writeNBuffer n f (Buffer p o u l) = do
252
252
253newBuffer :: Int -> ST s (Buffer s)
253newBuffer :: Int -> ST s (Buffer s)
254newBuffer size = do
254newBuffer size = do
255− arr <- A.unsafeNew size
255+ arr <- A.new size
256 return $! Buffer arr 0 0 size
256 return $! Buffer arr 0 0 size
257{-# INLINE newBuffer #-}
257{-# INLINE newBuffer #-}
258
258
Data/Text/Lazy/Fusion.hs+2−2
@@ -59,14 +59,14 @@ unstreamChunks chunkSize (Stream next s0 len0)
59 Skip s' -> outer s'
59 Skip s' -> outer s'
60 Yield x s' -> I.Text arr 0 len `chunk` outer s''
60 Yield x s' -> I.Text arr 0 len `chunk` outer s''
61 where (arr,(s'',len)) = A.run2 fill
61 where (arr,(s'',len)) = A.run2 fill
62− fill = do a <- A.unsafeNew unknownLength
62+ fill = do a <- A.new unknownLength
63 unsafeWrite a 0 x >>= inner a unknownLength s'
63 unsafeWrite a 0 x >>= inner a unknownLength s'
64 unknownLength = 4
64 unknownLength = 4
65 inner marr len s !i
65 inner marr len s !i
66 | i + 1 >= chunkSize = return (marr, (s,i))
66 | i + 1 >= chunkSize = return (marr, (s,i))
67 | i + 1 >= len = do
67 | i + 1 >= len = do
68 let newLen = min (len `shiftL` 1) chunkSize
68 let newLen = min (len `shiftL` 1) chunkSize
69− marr' <- A.unsafeNew newLen
69+ marr' <- A.new newLen
70 A.copyM marr' 0 marr 0 len
70 A.copyM marr' 0 marr 0 len
71 inner marr' newLen s i
71 inner marr' newLen s i
72 | otherwise =
72 | otherwise =
text.cabal+1−1
@@ -1,5 +1,5 @@
1name: text
1name: text
2−version: 0.9.0.1
2+version: 0.9.0.2
3homepage: http://code.haskell.org/text
3homepage: http://code.haskell.org/text
4synopsis: An efficient packed Unicode text type.
4synopsis: An efficient packed Unicode text type.
5description:
5description: