From 88cea8be53dcfed4bc7ec60c8f61c99afb4bc637 Mon Sep 17 00:00:00 2001 From: profan Date: Mon, 25 May 2026 11:58:51 +0100 Subject: [PATCH] claw back some time with skip locals init --- Program.cs | 19 ++++--------------- Sharpero.csproj | 1 + 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/Program.cs b/Program.cs index 6ed29c0..d674c38 100644 --- a/Program.cs +++ b/Program.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Numerics; using System.Reflection; using System.Reflection.Emit; +using System.Runtime.CompilerServices; using System.Threading.Tasks; using SkiaSharp; @@ -43,21 +44,7 @@ void CreateOutputImage(int imageSize, float[] imageData, string imageOutputPath) data.SaveTo(stream); } -enum OpCode -{ - VarX, - VarY, - Const, - Add, - Sub, - Mul, - Max, - Min, - Neg, - Square, - Sqrt -} - +enum OpCode { VarX, VarY, Const, Add, Sub, Mul, Max, Min, Neg, Square, Sqrt } readonly record struct Instruction(int Out, OpCode OpCode, int A = -1, int B = -1, float V = float.MaxValue); static class Parsing @@ -179,8 +166,10 @@ static class Interpreter return result; } + [SkipLocalsInit] public static Vector Evaluate(Instruction[] instructions, Vector xs, Vector ys) { + // #TODO: this construction is just a little bit unhinged lol Span> variables = stackalloc Vector[instructions.Length]; foreach (ref Instruction instruction in instructions.AsSpan()) diff --git a/Sharpero.csproj b/Sharpero.csproj index 749af92..ca920cb 100644 --- a/Sharpero.csproj +++ b/Sharpero.csproj @@ -4,6 +4,7 @@ Exe net10.0 enable + true