on master help sign in
Turn one error into a CAF
5cfe1e2Bryan O'Sullivan
Data/Text/Array.hs+4−1
@@ -114,7 +114,7 @@ instance IArray (MArray s) where
114-- | Create an uninitialized mutable array.
114-- | Create an uninitialized mutable array.
115new :: forall s. Int -> ST s (MArray s)
115new :: forall s. Int -> ST s (MArray s)
116new n
116new n
117− | n < 0 || n .&. highBit /= 0 = error $ "Data.Text.Array.new: size overflow"
117+ | n < 0 || n .&. highBit /= 0 = array_size_error
118 | otherwise = ST $ \s1# ->
118 | otherwise = ST $ \s1# ->
119 case newByteArray# len# s1# of
119 case newByteArray# len# s1# of
120 (# s2#, marr# #) -> (# s2#, MArray marr#
120 (# s2#, marr# #) -> (# s2#, MArray marr#
@@ -126,6 +126,9 @@ new n
126 highBit = maxBound `xor` (maxBound `shiftR` 1)
126 highBit = maxBound `xor` (maxBound `shiftR` 1)
127{-# INLINE new #-}
127{-# INLINE new #-}
128
128
129+array_size_error :: a
130+array_size_error = error "Data.Text.Array.new: size overflow"
131+
129-- | Freeze a mutable array. Do not mutate the 'MArray' afterwards!
132-- | Freeze a mutable array. Do not mutate the 'MArray' afterwards!
130unsafeFreeze :: MArray s -> ST s Array
133unsafeFreeze :: MArray s -> ST s Array
131unsafeFreeze MArray{..} = ST $ \s# ->
134unsafeFreeze MArray{..} = ST $ \s# ->