Commits

Aleksey Khudyakov committed 8b9647e

Inline methods in the indexable class

Comments (0)

Files changed (1)

Numeric/Classes/Indexing.hs

   (!)         :: a -> Int -> IndexVal a
   x ! i | i < 0 || i > size x = error "Numeric.Classes.Indexing.!: index is out of range"
         | otherwise           = unsafeIndex x i
+  {-# INLINE (!) #-}
 
 -- | Check that index is valid
 validIndex :: Indexable a => a -> Int -> Bool 
   size        = V.length
   unsafeIndex = V.unsafeIndex
   (!)         = (V.!)
+  {-# INLINE size        #-}
+  {-# INLINE (!)         #-}
+  {-# INLINE unsafeIndex #-}
 
 instance U.Unbox a => Indexable (U.Vector a) where
   type IndexVal (U.Vector a) = a
   size        = U.length
   unsafeIndex = U.unsafeIndex
   (!)         = (U.!)
+  {-# INLINE size        #-}
+  {-# INLINE (!)         #-}
+  {-# INLINE unsafeIndex #-}
 
 instance S.Storable a => Indexable (S.Vector a) where
   type IndexVal (S.Vector a) = a
   size        = S.length
   unsafeIndex = S.unsafeIndex
   (!)         = (S.!)
+  {-# INLINE size        #-}
+  {-# INLINE (!)         #-}
+  {-# INLINE unsafeIndex #-}