Skip to content

Commit 1c96521

Browse files
committed
perf: removes the lazy initialization since the node is always enumerated
Signed-off-by: Vincent Biret <[email protected]>
1 parent d3c758b commit 1c96521

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ private PropertyNode GetPropertyNodeFromJsonNode(string key, JsonNode? node)
2424
return new PropertyNode(Context, key, node ?? JsonNullSentinel.JsonNull);
2525
}
2626

27+
private readonly List<PropertyNode> _nodes;
2728
public MapNode(ParsingContext context, JsonNode node) : base(
2829
context, node)
2930
{
@@ -33,7 +34,7 @@ public MapNode(ParsingContext context, JsonNode node) : base(
3334
}
3435

3536
_node = mapNode;
36-
_nodes = new (() => _node.Select(p => GetPropertyNodeFromJsonNode(p.Key, p.Value)).ToList(), true);
37+
_nodes = _node.Select(p => GetPropertyNodeFromJsonNode(p.Key, p.Value)).ToList();
3738
}
3839

3940
public PropertyNode? this[string key]
@@ -131,10 +132,9 @@ public override Dictionary<string, HashSet<T>> CreateArrayMap<T>(Func<ValueNode,
131132
return nodes.ToDictionary(kvp => kvp.key, kvp => kvp.values);
132133
}
133134

134-
private readonly Lazy<List<PropertyNode>> _nodes;
135135
public IEnumerator<PropertyNode> GetEnumerator()
136136
{
137-
return _nodes.Value.GetEnumerator();
137+
return _nodes.GetEnumerator();
138138
}
139139

140140
IEnumerator IEnumerable.GetEnumerator()

0 commit comments

Comments
 (0)