Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions vector/src/Data/Vector/Storable/Unsafe.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import Control.Monad.Primitive
import Prelude
( Eq, Ord, Monoid, Read, Show, Ordering(..), Int, IO, Num(..)
, compare, mempty, mappend, mconcat, showsPrec, return, seq, undefined, div
, (<), (<=), (>), (>=), (==), (/=), (.), ($) )
, (<), (<=), (>), (>=), (==), (/=), (.), ($), ($!))

import Data.Data ( Data(..) )
import Text.Read ( Read(..), readListPrecDefault )
Expand Down Expand Up @@ -123,7 +123,7 @@ instance Storable a => G.Vector Vector a where
{-# INLINE basicUnsafeIndexM #-}
basicUnsafeIndexM (UnsafeVector _ fp) i
= return
. unsafeInlineIO
$! unsafeInlineIO
$ unsafeWithForeignPtr fp $ \p ->
peekElemOff p i

Expand Down
17 changes: 16 additions & 1 deletion vector/tests-inspect/Inspect/Alloc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import System.Mem
import Test.Alloc
import Test.Ignore

import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Storable as VS
import qualified Data.Vector.Strict as VV
import Inspect.Fusion


Expand Down Expand Up @@ -160,6 +162,11 @@ tests = testGroup "allocations"
[ allocWHNF "test_concat" test_concat listVectorI
]
]
, testGroup "indexing"
[ allocWHNF "== storable" (uncurry (==)) (vectorS,vectorS)
, allocWHNF "== unboxed" (uncurry (==)) (vectorI,vectorI)
, allocWHNF "== boxed" (uncurry (==)) (vectorV,vectorV)
]
]

allocWHNF :: String -> (a -> b) -> a -> TestTree
Expand Down Expand Up @@ -194,6 +201,14 @@ vectorI :: VU.Vector Int
{-# NOINLINE vectorI #-}
vectorI = VU.generate size fromIntegral

vectorS :: VS.Vector Int
{-# NOINLINE vectorS #-}
vectorS = VS.generate size fromIntegral

vectorV :: VV.Vector Int
{-# NOINLINE vectorV #-}
vectorV = VV.generate size fromIntegral

vectorIdx :: VU.Vector (Int,Int)
{-# NOINLINE vectorIdx #-}
vectorIdx = VU.map (\i -> (i`div`3, i)) vectorI
Expand Down
Loading