Skip to content

Commit

Permalink
Use TryGetValue instead of ContainsKey + []
Browse files Browse the repository at this point in the history
  • Loading branch information
barfeous committed Apr 28, 2024
1 parent 3448b64 commit 4a31621
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,11 @@ void merged_trackable(Trackable x)

public List<(string, Trackable)> list_dependencies(Trackable obj)
{
IDictionary<string, Trackable> children;
if (!_children_cache.ContainsKey(obj))
if (!_children_cache.TryGetValue(obj, out var children))
{
children= new Dictionary<string, Trackable>();
}
else
{
children= _children_cache[obj];
}

List<(string, Trackable)> res = new();
foreach(var pair in obj.deserialization_dependencies(children))
{
Expand Down

0 comments on commit 4a31621

Please sign in to comment.