I am involved in porting, improving, and D-atizing our correct SDK from C # to D. I am currently working on a Vector2 math module.
Will there be a performance difference between the two structures below? My tests show identical performance, but I would like to get a little understanding of experts :)
struct Vector2(T) { T x, y; @property T u() { return x; } @property T v() { return y; } @property void u(T value) { x = value; } @property void v(T value) { y = value; } } struct Vector2(T) { union { T x, u; } union { T y, v; } }
Obviously, I would like to use unions for syntactic simplicity. But are there any unforeseen pitfalls with their use? I am not familiar with their low-level details.
On the side of the note, I add a vector property syntax similar to HLSL / GLSL, for example vec1.yxz + = vec2.xyz; There is ... no .. a possible way to do this using union instead of @property?
F i l
source share