mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 14:23:40 +01:00
Remove array copy of handlers.
This commit is contained in:
parent
967c79fdd3
commit
1b4bee3d13
2 changed files with 10 additions and 15 deletions
|
|
@ -346,21 +346,17 @@ internal class AddonLifecyclePluginScoped : IDisposable, IServiceType, IAddonLif
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void UnregisterListener(IAddonLifecycle.AddonEventDelegate handler, params IAddonLifecycle.AddonEventDelegate[] handlers)
|
||||
public void UnregisterListener(params IAddonLifecycle.AddonEventDelegate[] handlers)
|
||||
{
|
||||
foreach (var listener in this.eventListeners.Where(entry => entry.FunctionDelegate == handler).ToArray())
|
||||
foreach (var handler in handlers)
|
||||
{
|
||||
this.addonLifecycleService.UnregisterListener(listener);
|
||||
this.eventListeners.Remove(listener);
|
||||
}
|
||||
this.eventListeners.RemoveAll(entry =>
|
||||
{
|
||||
if (entry.FunctionDelegate != handler) return false;
|
||||
|
||||
foreach (var handlerParma in handlers)
|
||||
{
|
||||
foreach (var listener in this.eventListeners.Where(entry => entry.FunctionDelegate == handlerParma).ToArray())
|
||||
{
|
||||
this.addonLifecycleService.UnregisterListener(listener);
|
||||
this.eventListeners.Remove(listener);
|
||||
}
|
||||
this.addonLifecycleService.UnregisterListener(entry);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,9 +77,8 @@ public interface IAddonLifecycle
|
|||
/// <summary>
|
||||
/// Unregister all events that use the specified handlers.
|
||||
/// </summary>
|
||||
/// <param name="handler">Event handler to remove.</param>
|
||||
/// <param name="handlers">Additional handlers to remove.</param>
|
||||
void UnregisterListener(AddonEventDelegate handler, params AddonEventDelegate[] handlers);
|
||||
/// <param name="handlers">Handlers to remove.</param>
|
||||
void UnregisterListener(params AddonEventDelegate[] handlers);
|
||||
|
||||
/// <summary>
|
||||
/// Addon argument data for use in event subscribers.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue