From 626452834fed7f15e20f2ecc0d4103be69621193 Mon Sep 17 00:00:00 2001 From: James Finlay Date: Mon, 7 Mar 2016 21:47:52 -0800 Subject: Perf improvements - The original '+=' of the GetHash method was taking ~10% of CPU usage for the game. This should improve performance considerably. - The next largest CPU usage we care about is the 'GetHash' method that gets called very often. Pulling the objects.GetHash() out will reduce hits on the method. --- StardewModdingAPI/Extensions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'StardewModdingAPI/Extensions.cs') diff --git a/StardewModdingAPI/Extensions.cs b/StardewModdingAPI/Extensions.cs index 7e849f12..c504f470 100644 --- a/StardewModdingAPI/Extensions.cs +++ b/StardewModdingAPI/Extensions.cs @@ -53,12 +53,12 @@ namespace StardewModdingAPI public static int GetHash(this IEnumerable enumerable) { - string s = string.Empty; + int hash = 0; foreach (var v in enumerable) { - s += v.GetHashCode().ToString(); + hash ^= v.GetHashCode(); } - return s.GetHashCode(); + return hash; } } } \ No newline at end of file -- cgit