From baf9003785ad3a27b735d3142ac58c83b6e2785c Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 17 Feb 2024 18:30:18 +0100 Subject: [PATCH] [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 117fa573fe7..cc3a0d8eb29 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 - include: flow-scalar-single-quoted - 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 - include: flow-scalar-single-quoted - 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