Skip to content

Commit 067c95a

Browse files
Copilotstephentoub
andcommitted
Enumerate _eventHandlers directly instead of .Keys to avoid lock and allocation
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
1 parent 39875c8 commit 067c95a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

dotnet/src/Session.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public IDisposable On(SessionEventHandler handler)
259259
/// </remarks>
260260
internal void DispatchEvent(SessionEvent sessionEvent)
261261
{
262-
foreach (var handler in _eventHandlers.Keys)
262+
foreach (var (handler, _) in _eventHandlers)
263263
{
264264
// We allow handler exceptions to propagate so they are not lost
265265
handler(sessionEvent);

0 commit comments

Comments
 (0)