diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-05-11 19:56:45 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-05-11 19:56:45 -0400 |
commit | 42a797a01240893e9a8e645253a269087b2d178d (patch) | |
tree | 6614238098f945e943b4ae7edc616485d3cb533a /src/SMAPI/Framework/InternalExtensions.cs | |
parent | 077c897d53371d12c812be5145d917c59583d7cb (diff) | |
download | SMAPI-42a797a01240893e9a8e645253a269087b2d178d.tar.gz SMAPI-42a797a01240893e9a8e645253a269087b2d178d.tar.bz2 SMAPI-42a797a01240893e9a8e645253a269087b2d178d.zip |
don't raise events that have no listeners
This mainly avoids allocating event arg objects unnecessarily.
Diffstat (limited to 'src/SMAPI/Framework/InternalExtensions.cs')
-rw-r--r-- | src/SMAPI/Framework/InternalExtensions.cs | 3 |
1 files changed, 2 insertions, 1 deletions
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 /// <param name="event">The event to raise.</param> public static void RaiseEmpty<TEventArgs>(this ManagedEvent<TEventArgs> @event) where TEventArgs : new() { - @event.Raise(Singleton<TEventArgs>.Instance); + if (@event.HasListeners) + @event.Raise(Singleton<TEventArgs>.Instance); } /**** |