Skip to content

Conversation

chriso
Copy link
Contributor

@chriso chriso commented Dec 8, 2021

There's no need to check for possible overflow before we handle each byte of input. We can just handle the next byte and then check whether overflow occurred. This shrinks the overflow checks in half.

amd64:

name old time/op new time/op delta Unmarshal/*json.codeResponse2-4 4.94ms ± 2% 4.74ms ± 1% -4.11% (p=0.008 n=5+5) name old speed new speed delta Unmarshal/*json.codeResponse2-4 393MB/s ± 2% 409MB/s ± 1% +4.27% (p=0.008 n=5+5) 

arm64:

name old time/op new time/op delta Unmarshal/*json.codeResponse2-10 4.43ms ± 0% 4.26ms ± 0% -3.82% (p=0.000 n=19+18) name old speed new speed delta Unmarshal/*json.codeResponse2-10 438MB/s ± 0% 455MB/s ± 0% +3.97% (p=0.000 n=19+18) 
There's no need to check for possible overflow before we handle each byte of input. We can just handle the next byte and then check whether overflow occurred.
Copy link
Contributor

@achille-roussel achille-roussel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@chriso chriso merged commit d2e2596 into master Dec 8, 2021
@chriso chriso deleted the improve-parse-uint branch December 8, 2021 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants