Skip to content

Commit

Permalink
Remove redundant containskey (#156)
Browse files Browse the repository at this point in the history
* remove redundant containskey

* .
  • Loading branch information
SimonCropp authored Apr 7, 2024
1 parent 9716052 commit d255830
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
19 changes: 2 additions & 17 deletions src/Alba/Internal/LightweightCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,7 @@ public TValue this[TKey key]
}
set
{
if (_values.ContainsKey(key))
{
_values[key] = value;
}
else
{
_values.Add(key, value);
}
_values[key] = value;
}
}

Expand Down Expand Up @@ -128,15 +121,7 @@ public void Fill(TKey key, TValue value)

public bool TryRetrieve(TKey key, [MaybeNullWhen(false)] out TValue value)
{
value = default;

if (_values.ContainsKey(key))
{
value = _values[key];
return true;
}

return false;
return _values.TryGetValue(key, out value);
}

public void Each(Action<TValue> action)
Expand Down
3 changes: 1 addition & 2 deletions src/IdentityServer.New/Pages/Diagnostics/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ public ViewModel(AuthenticateResult result)
{
AuthenticateResult = result;

if (result.Properties.Items.ContainsKey("client_list"))
if (result.Properties.Items.TryGetValue("client_list", out var encoded))
{
var encoded = result.Properties.Items["client_list"];
var bytes = Base64Url.Decode(encoded);
var value = Encoding.UTF8.GetString(bytes);

Expand Down

0 comments on commit d255830

Please sign in to comment.