Philip-Trettner / GlmSharp

Open-source semi-generated GLM-flavored math library for .NET/C#
MIT License
47 stars 18 forks source link

Unnecessary Object Creation #5

Open Philip-Trettner opened 7 years ago

Philip-Trettner commented 7 years ago

All optimizations of the following form:

public static vec4 Sub(vec4 lhs, vec4 rhs) => new vec4(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z, lhs.w - rhs.w);

to

public static vec4 Sub(vec4 lhs, vec4 rhs) {
    lhs.x -= rhs.x;
    lhs.y -= rhs.y;
    lhs.z -= rhs.z;
    lhs.w -= rhs.w;
    return lhs;
}

To optimize for stack usage and less object creation.