Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YAML] Improve Performance #3924

Merged
merged 2 commits into from
Feb 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions YAML/YAML.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,16 @@ variables:
_flow_scalar_end_plain_in: |- # kind of the negation of nb-ns-plain-in-line(c) c=plain-in
(?x:
(?=
\s* $
| \s+ \#
| \s* : (\s|$)
| \s* : {{c_flow_indicator}}
| \s* {{c_flow_indicator}}
\s+ \#
| \s* (?: $ | {{c_flow_indicator}} | : (?:\s|$|{{c_flow_indicator}}) )
Comment on lines +97 to +98
Copy link
Collaborator

@FichteFoll FichteFoll Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the effect on performance here caused by not grouping or by using a capturing group? Because I find the new grouping much harder to follow (though that could probably be solved by just splitting it over multiple lines).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The duplicate \s* had most impact.

)
)

_flow_scalar_end_plain_out: |- # kind of the negation of nb-ns-plain-in-line(c) c=plain-out
(?x:
(?=
\s* $
| \s+ \#
| \s* : (\s|$)
\s+ \#
| \s* (?: $ | : (?:\s|$))
)
)

Expand All @@ -125,7 +121,7 @@ variables:
)
\s*
:
(\s|$)
(?:\s|$)
)
)

Expand All @@ -143,7 +139,7 @@ variables:
)
\s*
:
(\s|$)
(?:\s|$)
)
)

Expand Down Expand Up @@ -229,15 +225,17 @@ contexts:
# http://yaml.org/spec/1.2/spec.html#style/block/
- include: block-scalar
- include: block-collection
- include: flow-scalar-plain-out-11 # needs higher priority than flow-node-11, which includes flow-scalar-plain-in
- include: flow-node-11
- include: flow-alias
- include: flow-collection
- include: flow-scalar-out-11

block-node-12:
# http://yaml.org/spec/1.2/spec.html#style/block/
- include: block-scalar
- include: block-collection
- include: flow-scalar-plain-out-12
- include: flow-node-12 # the -12 variant should not make a difference
- include: flow-alias
- include: flow-collection
- include: flow-scalar-out-12

block-collection:
# http://yaml.org/spec/1.2/spec.html#style/block/collection
Expand All @@ -249,32 +247,38 @@ contexts:
# ns-flow-yaml-node(n,c)
- include: flow-alias
- include: flow-collection
- include: flow-scalar-11
- include: flow-scalar-in-11

flow-node-12:
# http://yaml.org/spec/1.2/spec.html#style/flow/
# ns-flow-yaml-node(n,c)
- include: flow-alias
- include: flow-collection
- include: flow-scalar-12
- include: flow-scalar-in-12

flow-collection:
# http://yaml.org/spec/1.2/spec.html#style/flow/collection
- include: flow-sequence
- include: flow-mapping

flow-scalar-11:
flow-scalar-in-11:
# http://yaml.org/spec/1.2/spec.html#style/flow/scalar
- include: flow-scalar-double-quoted-in
- include: flow-scalar-single-quoted-in
- include: flow-scalar-plain-in-11

flow-scalar-12:
flow-scalar-in-12:
# http://yaml.org/spec/1.2/spec.html#style/flow/scalar
- include: flow-scalar-double-quoted-in
- include: flow-scalar-single-quoted-in
- include: flow-scalar-plain-in-12

flow-scalar-out-11:
# for block keys
- include: flow-scalar-double-quoted-out
- include: flow-scalar-single-quoted-out
- include: flow-scalar-plain-out-11

flow-scalar-out-12:
# for block keys
- include: flow-scalar-double-quoted-out
Expand Down
Loading