I have a struct called Vector2D. I use struct here to benefit from value types instead of references to instances, because vectors are intense with graphics generally. Last thing I want is thousands of vectors doing binary copies. Since the class just uses two floats (64 bits, then), it's not much of a concern, but I want to learn about this anyway.
I'd like to use operator overloading on my Vector2D struct. I'm worried this does at least three binary copies then: 1 binary copy with 'new', 2 binary copies passing in v1 and v2.
public static Vector2D operator +(Vector2D v1, Vector2D v2)
{
return new Vector2D(v1.m_x + v2.m_x, v1.m_y + v2.m_y);
}
Is there a different way to make this more efficient for structs?