Skip to content
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

Improve states readability with binary literrals #35

Open
nfroidure opened this issue Jun 3, 2018 · 3 comments
Open

Improve states readability with binary literrals #35

nfroidure opened this issue Jun 3, 2018 · 3 comments

Comments

@nfroidure
Copy link
Owner

nfroidure commented Jun 3, 2018

The parser states can now be expressed with the binary litteral operator:
https://github.com/nfroidure/svg-pathdata/blob/master/src/SVGPathDataParser.ts#L530-L541
http://2ality.com/2015/04/numbers-math-es6.html

@NaridaL
Copy link
Collaborator

NaridaL commented Jun 3, 2018

It's not quite clear to me why they're implemented as a bit mask anyway, apart from the relative flag, all the other states are mutually exclusive?

@nfroidure
Copy link
Owner Author

These states are also used and stored in the same variabl by the parser https://github.com/nfroidure/svg-pathdata/blob/master/src/SVGPathDataParser.ts#L511-L525

That said, the bit mask was really necessary to store the parser state, it doesn't save that much memory.

@NaridaL
Copy link
Collaborator

NaridaL commented Jun 3, 2018

You can do it with no explicit state var at all :-P https://github.com/nfroidure/svg-pathdata/blob/simpler-parser/src/SVGPathDataParser.ts

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

No branches or pull requests

2 participants