Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd3c758b

Browse files
committed
perf: switches to lazy instantiation
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
1 parent339f61f commitd3c758b

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
@@ -33,6 +33,7 @@ public MapNode(ParsingContext context, JsonNode node) : base(
3333
}
3434

3535
_node=mapNode;
36+
_nodes=new(()=>_node.Select(p=>GetPropertyNodeFromJsonNode(p.Key,p.Value)).ToList(),true);
3637
}
3738

3839
publicPropertyNode?this[stringkey]
@@ -130,11 +131,10 @@ public override Dictionary<string, HashSet<T>> CreateArrayMap<T>(Func<ValueNode,
130131
returnnodes.ToDictionary(kvp=>kvp.key, kvp=>kvp.values);
131132
}
132133

133-
privateList<PropertyNode>?_nodes;
134+
privatereadonlyLazy<List<PropertyNode>>_nodes;
134135
publicIEnumerator<PropertyNode>GetEnumerator()
135136
{
136-
_nodes??=_node.Select(p=>GetPropertyNodeFromJsonNode(p.Key,p.Value)).ToList();
137-
return_nodes.GetEnumerator();
137+
return_nodes.Value.GetEnumerator();
138138
}
139139

140140
IEnumeratorIEnumerable.GetEnumerator()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp