From: Shawdooow Date: Fri, 19 Nov 2021 20:37:59 +0000 (-0500) Subject: Use Unsafe since its faster X-Git-Tag: v0.2.4-beta~26 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=22845118450d05778a7cd4352854dea1ea6b1c85;p=jp%2Fvke.net.git Use Unsafe since its faster --- diff --git a/vke/src/Utils.cs b/vke/src/Utils.cs index 3324d7a..853067e 100644 --- a/vke/src/Utils.cs +++ b/vke/src/Utils.cs @@ -6,6 +6,7 @@ using System.IO; using System.Linq; using System.Numerics; using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Xml.Serialization; @@ -68,7 +69,7 @@ namespace Vulkan { /// Populate a Vector3 with values from a float array /// public static void FromFloatArray (ref Vector3 v, float[] floats) { - v = MemoryMarshal.Cast(floats)[0]; + v = Unsafe.As(ref floats)[0]; } /// /// Populate a Vector4 with values from a float array @@ -132,7 +133,7 @@ namespace Vulkan { #region Extensions methods public static void ImportFloatArray (this ref Vector3 v, float[] floats) { - v = MemoryMarshal.Cast(floats)[0]; + v = Unsafe.As(ref floats)[0]; } public static Vector3 Transform (this Vector3 v, ref Matrix4x4 mat, bool translate = false) { Vector4 v4 = Vector4.Transform (new Vector4 (v, translate ? 1f : 0f), mat);