From b3ac9f4bf8239ea2ccb76e7df77ba1cb8d41aee9 Mon Sep 17 00:00:00 2001 From: Gurgen Hakobyan Date: Wed, 18 Oct 2017 20:23:33 +0400 Subject: [PATCH] Not very important code optimization (#1030) Code optimization --- .../HubConnectionList.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNetCore.SignalR.Core/HubConnectionList.cs b/src/Microsoft.AspNetCore.SignalR.Core/HubConnectionList.cs index f57b5ec9ba..f398f87f2b 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/HubConnectionList.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/HubConnectionList.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; @@ -16,11 +15,8 @@ namespace Microsoft.AspNetCore.SignalR { get { - if (_connections.TryGetValue(connectionId, out var connection)) - { - return connection; - } - return null; + _connections.TryGetValue(connectionId, out var connection); + return connection; } } @@ -38,10 +34,7 @@ namespace Microsoft.AspNetCore.SignalR public IEnumerator GetEnumerator() { - foreach (var item in _connections) - { - yield return item.Value; - } + return _connections.Values.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator()