mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 05:43: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/>
|
/// <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.RemoveAll(entry =>
|
||||||
this.eventListeners.Remove(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var handlerParma in handlers)
|
|
||||||
{
|
|
||||||
foreach (var listener in this.eventListeners.Where(entry => entry.FunctionDelegate == handlerParma).ToArray())
|
|
||||||
{
|
{
|
||||||
this.addonLifecycleService.UnregisterListener(listener);
|
if (entry.FunctionDelegate != handler) return false;
|
||||||
this.eventListeners.Remove(listener);
|
|
||||||
}
|
this.addonLifecycleService.UnregisterListener(entry);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,9 +77,8 @@ public interface IAddonLifecycle
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unregister all events that use the specified handlers.
|
/// Unregister all events that use the specified handlers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="handler">Event handler to remove.</param>
|
/// <param name="handlers">Handlers to remove.</param>
|
||||||
/// <param name="handlers">Additional handlers to remove.</param>
|
void UnregisterListener(params AddonEventDelegate[] handlers);
|
||||||
void UnregisterListener(AddonEventDelegate handler, params AddonEventDelegate[] handlers);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Addon argument data for use in event subscribers.
|
/// Addon argument data for use in event subscribers.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue