summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/InternalExtensions.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-05-11 19:56:45 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-05-11 19:56:45 -0400
commit42a797a01240893e9a8e645253a269087b2d178d (patch)
tree6614238098f945e943b4ae7edc616485d3cb533a /src/SMAPI/Framework/InternalExtensions.cs
parent077c897d53371d12c812be5145d917c59583d7cb (diff)
downloadSMAPI-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.cs3
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);
}
/****