Browse Source

Use TryGetValue instead of ContainsKey + []

pull/1234/head
barfeous 1 year ago
parent
commit
4a31621a56
1 changed files with 2 additions and 6 deletions
  1. +2
    -6
      src/TensorFlowNET.Core/Training/Saving/SavedModel/AugmentedGraphView.cs

+ 2
- 6
src/TensorFlowNET.Core/Training/Saving/SavedModel/AugmentedGraphView.cs View File

@@ -109,15 +109,11 @@ public class AugmentedGraphView: ObjectGraphView

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))
{


Loading…
Cancel
Save