summaryrefslogtreecommitdiff
path: root/StardewModdingAPI/Inheritance
diff options
context:
space:
mode:
authorJames Finlay <jtfinlay@ualberta.ca>2016-03-07 21:47:52 -0800
committerJames Finlay <jtfinlay@ualberta.ca>2016-03-07 21:47:52 -0800
commit626452834fed7f15e20f2ecc0d4103be69621193 (patch)
tree2e7d130a11429bf98d1b5b5042e64d1912b43aee /StardewModdingAPI/Inheritance
parent38f59b079ec9f24c574d2681a41555038b291b03 (diff)
downloadSMAPI-626452834fed7f15e20f2ecc0d4103be69621193.tar.gz
SMAPI-626452834fed7f15e20f2ecc0d4103be69621193.tar.bz2
SMAPI-626452834fed7f15e20f2ecc0d4103be69621193.zip
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.
Diffstat (limited to 'StardewModdingAPI/Inheritance')
-rw-r--r--StardewModdingAPI/Inheritance/SGame.cs7
1 files changed, 4 insertions, 3 deletions
diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs
index cccdff23..735cd58a 100644
--- a/StardewModdingAPI/Inheritance/SGame.cs
+++ b/StardewModdingAPI/Inheritance/SGame.cs
@@ -465,12 +465,13 @@ namespace StardewModdingAPI.Inheritance
{
Events.PlayerEvents.InvokeInventoryChanged(player.items, changedItems);
PreviousItems = player.items.Where(n => n != null).ToDictionary(n => n, n => n.Stack);
- }
+ }
- if(currentLocation != null && PreviousLocationObjects != currentLocation.objects.GetHash())
+ var objectHash = currentLocation?.objects?.GetHash();
+ if(objectHash != null && PreviousLocationObjects != objectHash)
{
Events.LocationEvents.InvokeOnNewLocationObject(currentLocation.objects);
- PreviousLocationObjects = currentLocation.objects.GetHash();
+ PreviousLocationObjects = objectHash ?? -1;
}
if (timeOfDay != PreviousTimeOfDay)