Skip to content

Commit aaa23ed

Browse files
committed
use cached HasListeners in ManagedEvent.Raise for simplicity
1 parent e4f42f9 commit aaa23ed

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/SMAPI/Framework/Events/ManagedEvent.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ public void Remove(EventHandler<TEventArgs> handler)
9797
/// <param name="args">The event arguments to pass.</param>
9898
public void Raise(TEventArgs args)
9999
{
100-
// skip if no handlers
101-
if (this.Handlers.Count == 0)
100+
if (!this.HasListeners)
102101
return;
103102

104103
// raise event
@@ -125,8 +124,7 @@ public void Raise(TEventArgs args)
125124
/// <param name="invoke">Invoke an event handler. This receives the mod which registered the handler, and should invoke the callback with the event arguments to pass it.</param>
126125
public void Raise(Action<IModMetadata, Action<TEventArgs>> invoke)
127126
{
128-
// skip if no handlers
129-
if (this.Handlers.Count == 0)
127+
if (!this.HasListeners)
130128
return;
131129

132130
// raise event

0 commit comments

Comments
 (0)