dwmkerr / glmnet

GlmNet is a .NET version of the excellent OpenGL Mathematics library (GLM).
MIT License
53 stars 20 forks source link

Performance improvements #17

Open alektron opened 4 years ago

alektron commented 4 years ago

The usage of LINQ slowed down the conversion from matrices to arrays by a lot. I got massive performance improvements by simply getting rid of them (I had several thousand calls of to_array per frame in my render engine). The code I replaced LINQ with is really not complicated and I see absolutely no reason to use LINQ here.

Some vector operations were allocating new vector object while the operations can be performed without them as well so I removed them.

I also replaced a few index accesses on vectors with direct variable access which should be quite a bit faster as well since it avoids all the branches. The index operator really only is useful for iterating over the values.