Performance tweaks
This commit is contained in:
+18
-4
@@ -4,15 +4,29 @@ module Shape.Data
|
||||
where
|
||||
import Geometry.Data
|
||||
import Control.Lens
|
||||
--import qualified Data.Vector.Fusion.Stream.Monadic as VS
|
||||
import qualified Data.DList as DL
|
||||
|
||||
--import Data.Monoid
|
||||
data Shape = Shape
|
||||
{ _shVertices :: [ShapeV]
|
||||
, _shEdges :: [Point3]
|
||||
{ _shVertices :: DL.DList ShapeV
|
||||
, _shEdges :: DL.DList Point3
|
||||
}
|
||||
instance Semigroup Shape where
|
||||
(<>) (Shape sv1 se1) (Shape sv2 se2) = Shape (sv1 ++ sv2) (se1 ++ se2)
|
||||
(<>) (Shape sv1 se1) (Shape sv2 se2) = Shape (sv1 <> sv2) (se1 <> se2)
|
||||
--(<>) (Shape sv1 se1) (Shape sv2 se2) = Shape (sv1 VS.++ sv2) (se1 VS.++ se2)
|
||||
instance Monoid Shape where
|
||||
mempty = Shape [] []
|
||||
mempty = Shape mempty mempty
|
||||
|
||||
{-# INLINE shVList #-}
|
||||
shVList = DL.toList . _shVertices
|
||||
{-# INLINE shEList #-}
|
||||
shEList = DL.toList . _shEdges
|
||||
|
||||
{-# INLINE shVfromList #-}
|
||||
shVfromList = DL.fromList
|
||||
{-# INLINE shEfromList #-}
|
||||
shEfromList = DL.fromList
|
||||
|
||||
-- edges are given by four consecutive points
|
||||
data ShapeV = ShapeV
|
||||
|
||||
Reference in New Issue
Block a user