-
Notifications
You must be signed in to change notification settings - Fork 53
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
Optimize parseLiteral for number-heavy JSON files (ala GeoJSON) #34
Conversation
Cool. Do you have examples of numbers that need to go through JSON.parse ? We should add some test cases: https://github.com/microsoft/node-jsonc-parser/blob/master/src/test/json.test.ts#L180 |
Good call. I switched from According to MDN the only cases Number(...) may not have JSON-parity are when there is a leading zero, for example |
Actually, the scanner in scanNumber already ensures that the number format is correct following the spec from https://www.json.org/json-en.html. You changes look good. Any additional tests you want to add or are we already covered well enough? |
I think the tests are already sufficient, I double checked to make sure exponent corner cases were tested. Thanks! |
Hi @aeschli , are there any updates on this PR? Thanks! |
@mbullington Sorry for the wait, thanks for the PR! |
When parsing number-heavy files like GeoJSON, trying the naive
parseFloat
first then going for full JSON compatibility ifNaN
provides meaningful performance benefits.Tried on a 75MB GeoJSON file, raw parse time was ~3500ms before change and ~2600-2700ms after.
Best.