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

restore special case parsing of numbers for in memory JSON #265

Merged
merged 1 commit into from
Nov 10, 2018

Conversation

KristofferC
Copy link
Member

@KristofferC KristofferC commented Nov 4, 2018

I was trying to figure out why the from and to variables where threaded through the number parsing routines since it seemed like they were always 1 and length(ps.utf8array) respectively. Turns out there is a special cased number parser for in-memory JSON that is being failed to be dispatched to after the introduction of ParserContext (#224 cc @kmsquire).

This restores the special case for a nice performance boost:

using JSON
using BenchmarkTools

a = string("[", join([rand(Int) for i in 1:10^3], ","), "]");
@btime JSON.parse($a)

Before:

julia> @btime JSON.parse($a)
  246.210 μs (1016 allocations: 32.33 KiB)

After:

julia> @btime JSON.parse($a)
  89.930 μs (1011 allocations: 32.11 KiB)

Arguably the parse_number(pc::ParserContext, ps::ParserState) should be changed to parse_number(pc::ParserContext, ps::StreamingParserState) to avoid this happening again.

@TotalVerb
Copy link
Collaborator

LGTM. Not sure why the codecov is failing, since this improves coverage.

@KristofferC
Copy link
Member Author

Coverage is fubar...

@TotalVerb TotalVerb merged commit 8d4346e into JuliaIO:master Nov 10, 2018
@KristofferC KristofferC deleted the kc/restore_spec branch September 7, 2020 11:29
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.

2 participants