Skip to content

Remove more bytes from parser #401

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: master
Choose a base branch
from
Open

Conversation

blakeembrey
Copy link
Member

Realized using the same token type strings would improve compression and found some other small byte savings. At this point the next largest size improvement would be moving to ESM so I think this is the last bump available, but I welcome PRs that remove more bytes in the minified output without affecting readability.

Before: 1.93 kB
After: 1.88 kB

@blakeembrey blakeembrey requested a review from a team August 25, 2025 19:36
Copy link

codecov bot commented Aug 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2a7f2a4) to head (77d6189).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #401   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          378       369    -9     
  Branches       136       132    -4     
=========================================
- Hits           378       369    -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

if (next.type !== "CHAR" && next.type !== "ESCAPED") break;
pos++;
path += next.value;
const token = tokens[pos++];
Copy link
Member Author

Choose a reason for hiding this comment

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

Surprised me, but removing destructuring helped.

| "wildcard"
| "param"
| "char"
| "escape"
Copy link
Member Author

Choose a reason for hiding this comment

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

"ESCAPED" -> "escape" arguably reads better in an error (Unexpected escape at index 12). That said, I don't think type would ever show in an error anyway, the only unexpected token is "end".

| "param"
| "char"
| "escape"
| "end"
Copy link
Member Author

Choose a reason for hiding this comment

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

All these types are also internal only, never exposed, so renaming them is safe (only the error changes for "Unexpected END").

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.

1 participant