Skip to content

KCL: Try parsing [1, 2, 3] before [1..3] #7859

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adamchalmers
Copy link
Contributor

@adamchalmers adamchalmers commented Jul 20, 2025

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 significantly on my macbook (15-45%):

Screenshot 2025-07-20 at 8 24 29 AM

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.
@adamchalmers adamchalmers requested a review from a team as a code owner July 20, 2025 13:18
Copy link

vercel bot commented Jul 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 20, 2025 1:32pm

Copy link
Contributor

@jtran jtran left a comment

Choose a reason for hiding this comment

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

💯

@adamchalmers
Copy link
Contributor Author

Confused why this made a bunch of tests fail, I guess because in the case of errors we do ErrMode::Cut instead of ErrMode::Backtrack. But we need to do Cut to prevent the compiler error from being swallowed. Hmm.

@jtran
Copy link
Contributor

jtran commented Jul 24, 2025

In array_elem_by_elem we need to cut only if it can't be an array range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants