Cheng Shao pushed to branch wip/binary-array-no-list at Glasgow Haskell Compiler / GHC
Commits:
-
1a713d56
by Cheng Shao at 2026-04-08T11:11:39+00:00
1 changed file:
Changes:
| ... | ... | @@ -142,6 +142,8 @@ import Control.DeepSeq |
| 142 | 142 | import Control.Monad ( when, (<$!>), unless, forM_, void )
|
| 143 | 143 | import Foreign hiding (bit, setBit, clearBit, shiftL, shiftR, void)
|
| 144 | 144 | import Data.Array
|
| 145 | +import Data.Array.Base (unsafeFreezeIOArray)
|
|
| 146 | +import Data.Array.IArray (traverseArray_)
|
|
| 145 | 147 | import Data.Array.IO
|
| 146 | 148 | import Data.Array.Unsafe
|
| 147 | 149 | import qualified Data.Binary as Binary
|
| ... | ... | @@ -970,11 +972,12 @@ instance Binary a => Binary (NonEmpty a) where |
| 970 | 972 | instance (Ix a, Binary a, Binary b) => Binary (Array a b) where
|
| 971 | 973 | put_ bh arr = do
|
| 972 | 974 | put_ bh $ bounds arr
|
| 973 | - put_ bh $ elems arr
|
|
| 975 | + traverseArray_ (put_ bh) arr
|
|
| 976 | + |
|
| 974 | 977 | get bh = do
|
| 975 | - bounds <- get bh
|
|
| 976 | - xs <- get bh
|
|
| 977 | - return $ listArray bounds xs
|
|
| 978 | + (l, u) <- get bh
|
|
| 979 | + marr <- newGenArray (l, u) $ \_ -> get bh
|
|
| 980 | + unsafeFreezeIOArray marr
|
|
| 978 | 981 | |
| 979 | 982 | instance Binary a => Binary (SmallArray a) where
|
| 980 | 983 | put_ bh sa = do
|