Performance tweaks

This commit is contained in:
2021-09-18 15:38:46 +01:00
parent 2d8f1089a1
commit 80aa67015c
10 changed files with 194 additions and 160 deletions
+18 -4
View File
@@ -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