-
-
Notifications
You must be signed in to change notification settings - Fork 443
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
if (next.type !== "CHAR" && next.type !== "ESCAPED") break; | ||
pos++; | ||
path += next.value; | ||
const token = tokens[pos++]; |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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").
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