From 39e98246a0e9e408166b11aa2279506ff225ff14 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 17 Feb 2024 17:56:14 +0100 Subject: [PATCH 1/2] [YAML] Optimize scalar patterns This commit improves parsing performance by about 4-6%. --- YAML/YAML.sublime-syntax | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/YAML/YAML.sublime-syntax b/YAML/YAML.sublime-syntax index 1cae918e96..1856384d40 100644 --- a/YAML/YAML.sublime-syntax +++ b/YAML/YAML.sublime-syntax @@ -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}}) ) ) ) _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|$)) ) ) @@ -125,7 +121,7 @@ variables: ) \s* : - (\s|$) + (?:\s|$) ) ) @@ -143,7 +139,7 @@ variables: ) \s* : - (\s|$) + (?:\s|$) ) ) From 5620b3d363f8ac8588013ef271e4a9c1a06cecb8 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 17 Feb 2024 18:30:18 +0100 Subject: [PATCH 2/2] [YAML] Optimize scalar contexts This commit improves parsing performance by about 16%. It reorganizes imports in `block-node-11` and `block-node-12` contexts in order to avoid `flow-scalar-plain-out-1x` and `flow-scalar-plain-in-1x` being included at the same time. --- YAML/YAML.sublime-syntax | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/YAML/YAML.sublime-syntax b/YAML/YAML.sublime-syntax index 1856384d40..f4999e6157 100644 --- a/YAML/YAML.sublime-syntax +++ b/YAML/YAML.sublime-syntax @@ -225,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 @@ -245,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