-
Notifications
You must be signed in to change notification settings - Fork 17
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
Editorial: add a 'decode a list of base64 VLQ' algorithm #130
base: main
Are you sure you want to change the base?
Conversation
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.
Can we keep the optional error for a non-1/4/5 length segment?
My code will be slightly out of spec since we'll eat the ,
as a 0
value and continue reading values from the next segment. I see if I can instead limit my position to < commaIndex
without adding more checks.
@szuend If you still need this PR for scopes, could you do what Justin suggested above (to avoid introducing observable changes) and rebase? |
The decoding algorithms for scopes are very unwieldy, and having the format implicitly defined by a decoding algorithm makes it very hard to understand. I'm wondering if we should go a different route and follow ecma262: Define the encoded format as a grammar and use syntax-directed operations for turning the grammar rules into structs. Ecma262 doesn't spell out a parsing algorithm after all where-as we do that currently in the source map spec. |
EDIT: You wrote exactly what I suggested, sorry 😅 Yes, we could try doing that. |
This PR extracts a 'decode a list of base64 VLQ' algorithm that consumes a string wholly and returns all contained VLQ numbers as a list. We can share this algorithm between decoding
mappings
andoriginalScopes
/generatedRanges
of the scopes proposal.It also makes the algorithm slightly more readable as we can get rid of
position
and we don't necessarily need therelative*
variables as they only have a single use-site.