ImplicitCAD icon indicating copy to clipboard operation
ImplicitCAD copied to clipboard

getImplicit implementations should lift recursive calls outside of the lambda

Open isovector opened this issue 4 years ago • 0 comments

eg:

https://github.com/colah/ImplicitCAD/blob/742638a33e92d814267481b0fd7418b9a7afc050/Graphics/Implicit/ObjectUtil/GetImplicitShared.hs#L56-L57

Because the let binding is inside the lambda here, the runtime is going to call getImplicit on every child for every point it samples. If we instead pull it out:

getImplicitShared (UnionR r symbObjs) =
  let objs = fmap getImplicit symbObjs
   in \p -> rminimum r $ fmap ($ p) objs

we can amortize that work

isovector avatar Dec 20 '20 02:12 isovector