Decode JSON literal types eagerly and with our own decoder.
Previously we relied on Double.parseDouble() to decode tokens. Since
that method is expensive, we deferred calling it unless absolutely
necessary.
Now we decode the literal type immediately. For efficiency we decode
the token right out of the char buffer. This makes things more
complicated but it saves many calls to charAt().
With this change overall performance is 7% faster for JSON documents
cited in the bug.
benchmark run ms linear runtime %
GsonParseFull no switch, no int parse 309 ============================ 93%
GsonParseFull baseline 330 ============================== 100%
http://b/3201883
Change-Id: I436b6769956b1357a17c807a327d3a234691c73f
2 files changed