Browse Source

Drop an unnecessary constructor invocation for perf

af/merge-core
James Jackson-South 8 years ago
parent
commit
05775a3ed1
  1. 8
      src/ImageSharp/Common/Extensions/Vector4Extensions.cs

8
src/ImageSharp/Common/Extensions/Vector4Extensions.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp
internal static class Vector4Extensions internal static class Vector4Extensions
{ {
/// <summary> /// <summary>
/// Premultiplies the "x", "y", "z" components of a vector by its "w" component leaving the "w" component intact. /// Pre-multiplies the "x", "y", "z" components of a vector by its "w" component leaving the "w" component intact.
/// </summary> /// </summary>
/// <param name="source">The <see cref="Vector4"/> to premultiply</param> /// <param name="source">The <see cref="Vector4"/> to premultiply</param>
/// <returns>The <see cref="Vector4"/></returns> /// <returns>The <see cref="Vector4"/></returns>
@ -22,7 +22,8 @@ namespace SixLabors.ImageSharp
{ {
float w = source.W; float w = source.W;
Vector4 premultiplied = source * w; Vector4 premultiplied = source * w;
return new Vector4(premultiplied.X, premultiplied.Y, premultiplied.Z, w); premultiplied.W = w;
return premultiplied;
} }
/// <summary> /// <summary>
@ -35,7 +36,8 @@ namespace SixLabors.ImageSharp
{ {
float w = source.W; float w = source.W;
Vector4 unpremultiplied = source / w; Vector4 unpremultiplied = source / w;
return new Vector4(unpremultiplied.X, unpremultiplied.Y, unpremultiplied.Z, w); unpremultiplied.W = w;
return unpremultiplied;
} }
/// <summary> /// <summary>

Loading…
Cancel
Save