Skip to content

Commit

Permalink
microptimize the check for valid digit
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Nov 2, 2018
1 parent 9fb529c commit b480e98
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,9 @@ function int_from_bytes(pc::ParserContext{<:Any,IntType},
num = IntType(0)
@inbounds for i in from:to
c = bytes[i]
if isjsondigit(c)
num = IntType(10) * num + IntType(c - DIGIT_ZERO)
dig = c - DIGIT_ZERO
if dig < 0x10

This comment has been minimized.

Copy link
@TotalVerb

TotalVerb Nov 4, 2018

Collaborator

We probably need a lower bound here too.

This comment has been minimized.

Copy link
@KristofferC

KristofferC Nov 4, 2018

Author Member

Nope :)

This comment has been minimized.

Copy link
@TotalVerb

TotalVerb Nov 4, 2018

Collaborator

Ah neat, this is unsigned arithmetic. Cool, lgtm.

num = IntType(10) * num + IntType(dig)
else
_error(E_BAD_NUMBER, ps)
end
Expand Down

0 comments on commit b480e98

Please sign in to comment.