perf(eventbus): remove inline allocations and expose binding snapshots
Publish NuGet packages / publish (push) Successful in 2m37s
Publish UPM package / publish (push) Successful in 2s

This commit is contained in:
2026-09-29 10:14:45 +08:00
parent c44a7e6dda
commit a92c9d2cea
7 changed files with 50 additions and 10 deletions
+10
View File
@@ -14,6 +14,7 @@ namespace ShrinkEventBus
internal interface IShrinkEventChannel
{
int Count { get; }
void CaptureBindings(List<(Type EventType, System.Reflection.MethodInfo Handler)> bindings);
bool RemoveSubscription(long subscriptionId);
void Clear();
void DetachSlot(int slot);
@@ -87,6 +88,15 @@ namespace ShrinkEventBus
private Action<TEvent>? _syncDispatcher;
public int Count => _snapshot.Length;
public void CaptureBindings(List<(Type EventType, System.Reflection.MethodInfo Handler)> bindings)
{
var snapshot = _snapshot;
foreach (var entry in snapshot)
{
var method = entry.SyncHandler?.Method ?? entry.AsyncHandler?.Method;
if (method != null) bindings.Add((typeof(TEvent), method));
}
}
public void Add(long subscriptionId, long registrationOrder, Action<TEvent> handler,
ShrinkSubscribeDescriptor descriptor)