Skip to content

Commit 4a31621

Browse files
committed
Use TryGetValue instead of ContainsKey + []
1 parent 3448b64 commit 4a31621

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/TensorFlowNET.Core/Training/Saving/SavedModel/AugmentedGraphView.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,11 @@ void merged_trackable(Trackable x)
109109

110110
public List<(string, Trackable)> list_dependencies(Trackable obj)
111111
{
112-
IDictionary<string, Trackable> children;
113-
if (!_children_cache.ContainsKey(obj))
112+
if (!_children_cache.TryGetValue(obj, out var children))
114113
{
115114
children= new Dictionary<string, Trackable>();
116115
}
117-
else
118-
{
119-
children= _children_cache[obj];
120-
}
116+
121117
List<(string, Trackable)> res = new();
122118
foreach(var pair in obj.deserialization_dependencies(children))
123119
{

0 commit comments

Comments
 (0)