mirror of
https://github.com/composewell/streamly.git
synced 2024-10-27 20:18:55 +03:00
Assert length is multiple of elemSize
This commit is contained in:
parent
f700973876
commit
e870b5cdb7
@ -455,7 +455,10 @@ byteLength Array{..} =
|
||||
-- @since 0.7.0
|
||||
{-# INLINE length #-}
|
||||
length :: forall a. Storable a => Array a -> Int
|
||||
length arr = byteLength arr `div` sizeOf (undefined :: a)
|
||||
length arr =
|
||||
let elemSize = sizeOf (undefined :: a)
|
||||
blen = byteLength arr
|
||||
in assert (blen `mod` elemSize == 0) (blen `div` elemSize)
|
||||
|
||||
-- | Get the total capacity of an array. An array may have space reserved
|
||||
-- beyond the current used length of the array.
|
||||
|
Loading…
Reference in New Issue
Block a user