From: Egor Bogatov Date: Mon, 4 May 2020 21:06:17 +0000 (+0300) Subject: Optimize Vector4.Lerp (#35525) X-Git-Tag: submit/tizen/20210909.063632~8204 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2848dbfc4df320ceee4b6279c8f6c943669b3991;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Optimize Vector4.Lerp (#35525) * Optimize Vector4.Lerp * Implement for Vector2 and Vector4 * Rollback Vector3 --- diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector2.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector2.cs index dc74961..38b5722 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector2.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector2.cs @@ -207,9 +207,7 @@ namespace System.Numerics [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector2 Lerp(Vector2 value1, Vector2 value2, float amount) { - return new Vector2( - value1.X + (value2.X - value1.X) * amount, - value1.Y + (value2.Y - value1.Y) * amount); + return value1 + (value2 - value1) * amount; } /// diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector4.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector4.cs index 30dd343..45a9f42 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector4.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector4.cs @@ -209,11 +209,7 @@ namespace System.Numerics [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount) { - return new Vector4( - value1.X + (value2.X - value1.X) * amount, - value1.Y + (value2.Y - value1.Y) * amount, - value1.Z + (value2.Z - value1.Z) * amount, - value1.W + (value2.W - value1.W) * amount); + return value1 + (value2 - value1) * amount; } ///