From e9ba7c96b993855ed4e30e46317ce5d6391bbb5a Mon Sep 17 00:00:00 2001 From: Katie Durden Date: Sat, 25 Feb 2023 21:49:27 -0800 Subject: [PATCH] Changes `searched` from List to HashSet; saves ~43ms in `SearchLocation --- stardew-access/Features/Radar.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stardew-access/Features/Radar.cs b/stardew-access/Features/Radar.cs index 558da81..5434f97 100644 --- a/stardew-access/Features/Radar.cs +++ b/stardew-access/Features/Radar.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using Microsoft.Xna.Framework; using StardewValley; using StardewValley.Objects; @@ -94,7 +95,7 @@ namespace stardew_access.Features Dictionary detectedTiles = new Dictionary(); Queue toSearch = new Queue(); - List searched = new List(); + HashSet searched = new HashSet(); int[] dirX = { -1, 0, 1, 0 }; int[] dirY = { 0, 1, 0, -1 }; @@ -142,7 +143,7 @@ namespace stardew_access.Features (bool, string? name, string category) tileInfo; Queue toSearch = new Queue(); - List searched = new List(); + HashSet searched = new HashSet(); int[] dirX = { -1, 0, 1, 0 }; int[] dirY = { 0, 1, 0, -1 }; int count = 0; @@ -185,7 +186,7 @@ namespace stardew_access.Features /// The list of searched items. /// The radius of search /// Returns true if the tile is valid for search. - public bool isValid(Vector2 item, Vector2 center, List searched, int limit) + public bool isValid(Vector2 item, Vector2 center, HashSet searched, int limit) { if (Math.Abs(item.X - center.X) > limit) return false;