From 42a797a01240893e9a8e645253a269087b2d178d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 11 May 2022 19:56:45 -0400 Subject: don't raise events that have no listeners This mainly avoids allocating event arg objects unnecessarily. --- src/SMAPI/Framework/InternalExtensions.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/SMAPI/Framework/InternalExtensions.cs') diff --git a/src/SMAPI/Framework/InternalExtensions.cs b/src/SMAPI/Framework/InternalExtensions.cs index 580651f3..ba9bbcec 100644 --- a/src/SMAPI/Framework/InternalExtensions.cs +++ b/src/SMAPI/Framework/InternalExtensions.cs @@ -64,7 +64,8 @@ namespace StardewModdingAPI.Framework /// The event to raise. public static void RaiseEmpty(this ManagedEvent @event) where TEventArgs : new() { - @event.Raise(Singleton.Instance); + if (@event.HasListeners) + @event.Raise(Singleton.Instance); } /**** -- cgit