diff options
| author | cvium <clausvium@gmail.com> | 2021-04-30 15:09:36 +0200 |
|---|---|---|
| committer | cvium <clausvium@gmail.com> | 2021-04-30 15:09:36 +0200 |
| commit | 608cba817c54df60959079719bafca4d7d54269a (patch) | |
| tree | db024902a82c5ec64ffc88c0827d4f891cf45983 /Emby.Server.Implementations/QuickConnect | |
| parent | eeb5d4bd1e63ad89f599fd52a79b3c80ed8f8ad1 (diff) | |
Reduce some allocations with the magic of spans etc.
Diffstat (limited to 'Emby.Server.Implementations/QuickConnect')
| -rw-r--r-- | Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs index 22739a008..0259dc436 100644 --- a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs +++ b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs @@ -257,20 +257,17 @@ namespace Emby.Server.Implementations.QuickConnect } // Expire stale connection requests - var code = string.Empty; - var values = _currentRequests.Values.ToList(); - - for (int i = 0; i < values.Count; i++) + foreach (var (_, currentRequest) in _currentRequests) { - var added = values[i].DateAdded ?? DateTime.UnixEpoch; - if (DateTime.UtcNow > added.AddMinutes(Timeout) || expireAll) + var added = currentRequest.DateAdded ?? DateTime.UnixEpoch; + if (expireAll || DateTime.UtcNow > added.AddMinutes(Timeout)) { - code = values[i].Code; - _logger.LogDebug("Removing expired request {code}", code); + var code = currentRequest.Code; + _logger.LogDebug("Removing expired request {Code}", code); if (!_currentRequests.TryRemove(code, out _)) { - _logger.LogWarning("Request {code} already expired", code); + _logger.LogWarning("Request {Code} already expired", code); } } } |
