On Friday, 13 December 2013 at 12:41:53 UTC, logicchains wrote:
I've posted a couple of benchmarks involving D previously and
received complaints that the D implementation was ugly and
un-idiomatic, so I thought I'd seek code review before posting
the next one. The code is at
https://github.com/logicchains/ParticleBench/blob/master/D.d;
it's an OpenGL particle animation, and my D code is essentially
just a direct port of the C implementation. Note however that,
as the animation is gpu-bound, there's not much scope for
optimisation of the code (in hindsight, it was a pretty poor
topic for a benchmark, but hindsight always sees farthest and
whatnot).
You have a lot of global variables of same type. With very
similar default values.
Example windX and runTmr. They are both doubles.
Perhaps an alternative way to write it is like this:
double
windX = 0,
runTmr = 0;
You also have a lot of enums that like WIDTH and HEIGHT that
could be transformed into a single enum.
e.g.
enum int WIDTH = 800;
enum int HEIGHT = 600;
Would become:
enum : int {
WIDTH = 800,
HEIGHT = 600
}
Adds a couple extra lines but hey when you got 20 odd values and
repeating the type it kinda looks ugly.
Nothing really huge to say. I would say not use e.g. Derelict for
bindings but when you're not timing that then no point.
Also check your formatting currently its not consistent. There is
some brackets with and without spaces before / after.
Otherwise not too badly done.