From 1a28f04c429724415a78207d1106ec37049b6e31 Mon Sep 17 00:00:00 2001 From: Adam Chalmers Date: Sun, 20 Jul 2025 08:16:45 -0500 Subject: [PATCH] KCL: Try parsing [1, 2, 3] before [1..3] Arrays can be either element-by-element or a range. KCL programs use element-by-element more, because that's how points and axes are represented. We should parse the more common case (elemnt-by-element) before trying the less common case (ranges). This change improves parse speed by ~20-30% on my macbook. --- rust/kcl-lib/src/parsing/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/kcl-lib/src/parsing/parser.rs b/rust/kcl-lib/src/parsing/parser.rs index f7a8b60da21..69b837114e4 100644 --- a/rust/kcl-lib/src/parsing/parser.rs +++ b/rust/kcl-lib/src/parsing/parser.rs @@ -748,8 +748,8 @@ pub enum NonCodeOr { fn array(i: &mut TokenSlice) -> ModalResult { alt(( array_empty.map(Box::new).map(Expr::ArrayExpression), - array_end_start.map(Box::new).map(Expr::ArrayRangeExpression), array_elem_by_elem.map(Box::new).map(Expr::ArrayExpression), + array_end_start.map(Box::new).map(Expr::ArrayRangeExpression), )) .parse_next(i) }