Skip to content

Commit

Permalink
perf: skip children walking if unneeded (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip authored Apr 11, 2019
1 parent 15522ca commit fe339cb
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/getJsonPathForPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function* walk(node: YAMLNode): IterableIterator<YAMLNode> {
for (const mapping of (node as YamlMap).mappings) {
if (isValidNode(mapping)) {
yield mapping;
yield* walk(mapping);
}
}
}
Expand All @@ -41,10 +40,6 @@ function* walk(node: YAMLNode): IterableIterator<YAMLNode> {

if (isValidNode((node as YAMLMapping).value)) {
yield (node as YAMLMapping).value;

if ((node as YAMLMapping).value.kind === Kind.MAP || (node as YAMLMapping).value.kind === Kind.SEQ) {
yield* walk(node.value);
}
}

break;
Expand All @@ -53,7 +48,6 @@ function* walk(node: YAMLNode): IterableIterator<YAMLNode> {
for (const item of (node as YAMLSequence).items) {
if (isValidNode(item)) {
yield item;
yield* walk(item);
}
}
}
Expand Down

0 comments on commit fe339cb

Please sign in to comment.