From 1dae3bd1016d729c8378bf7d5a18744567931042 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 24 Jan 2018 12:06:43 +1100 Subject: [PATCH] Drop an unnecessary constructor invocation for perf --- src/ImageSharp/Common/Extensions/Vector4Extensions.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Common/Extensions/Vector4Extensions.cs b/src/ImageSharp/Common/Extensions/Vector4Extensions.cs index 64ebeb1f33..8133ebb38e 100644 --- a/src/ImageSharp/Common/Extensions/Vector4Extensions.cs +++ b/src/ImageSharp/Common/Extensions/Vector4Extensions.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp internal static class Vector4Extensions { /// - /// 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. /// /// The to premultiply /// The @@ -22,7 +22,8 @@ namespace SixLabors.ImageSharp { float w = source.W; Vector4 premultiplied = source * w; - return new Vector4(premultiplied.X, premultiplied.Y, premultiplied.Z, w); + premultiplied.W = w; + return premultiplied; } /// @@ -35,7 +36,8 @@ namespace SixLabors.ImageSharp { float w = source.W; Vector4 unpremultiplied = source / w; - return new Vector4(unpremultiplied.X, unpremultiplied.Y, unpremultiplied.Z, w); + unpremultiplied.W = w; + return unpremultiplied; } ///