From ea72d125660666de3d85703d936893a4b5fa0f16 Mon Sep 17 00:00:00 2001 From: Parnic Date: Thu, 15 Dec 2022 14:47:00 -0600 Subject: [PATCH] Quick perf improvement Day 15 part 2 is now ~300ms on my PC with my dataset in Release (~1s in Debug, which is...striking). --- src/Util/Vec2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Util/Vec2.cs b/src/Util/Vec2.cs index 6ed9296..b2a48f8 100644 --- a/src/Util/Vec2.cs +++ b/src/Util/Vec2.cs @@ -37,7 +37,7 @@ public struct ivec2 : IEquatable, IComparable, IComparable public float Length => MathF.Sqrt(LengthSquared); public int ManhattanDistance => Abs(this).Sum; - public int ManhattanDistanceTo(ivec2 other) => (this - other).ManhattanDistance; + public int ManhattanDistanceTo(ivec2 other) => System.Math.Abs(x - other.x) + System.Math.Abs(y - other.y); public ivec2 GetBestDirectionTo(ivec2 p) {