From 91eafcc47d08689b560f0f642c3e2e36c8dc85ce Mon Sep 17 00:00:00 2001 From: Simon Rodriguez Date: Wed, 13 Nov 2019 00:10:45 +0100 Subject: [PATCH] the + and * was creating a lot of new vector2s, went down 80% in call time with this --- Scripts/Editor/NodeEditorGUI.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Scripts/Editor/NodeEditorGUI.cs b/Scripts/Editor/NodeEditorGUI.cs index 1feec0e..30c26b4 100644 --- a/Scripts/Editor/NodeEditorGUI.cs +++ b/Scripts/Editor/NodeEditorGUI.cs @@ -121,7 +121,10 @@ namespace XNodeEditor { float u = 1 - t; float tt = t * t, uu = u * u; float uuu = uu * u, ttt = tt * t; - return (uuu * p0) + (3 * uu * t * p1) + (3 * u * tt * p2) + (ttt * p3); + return new Vector2( + (uuu * p0.x) + (3 * uu * t * p1.x) + (3 * u * tt * p2.x) + (ttt * p3.x), + (uuu * p0.y) + (3 * uu * t * p1.y) + (3 * u * tt * p2.y) + (ttt * p3.y) + ); } /// Draws a line segment without allocating temporary arrays