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

encoding/json: optimize isValidNumber #54705

Closed
amarjeetanandsingh opened this issue Aug 27, 2022 · 2 comments
Closed

encoding/json: optimize isValidNumber #54705

amarjeetanandsingh opened this issue Aug 27, 2022 · 2 comments

Comments

@amarjeetanandsingh
Copy link
Contributor

isValidNumber() performance can be optimized by avoiding substring creation in for loop.

benchstat oldBench.txt newBench.txt 
name             old time/op    new time/op    delta
NumberIsValid-8    39.3ns ± 1%    28.1ns ± 4%  -28.53%  (p=0.000 n=9+10)

name             old alloc/op   new alloc/op   delta
NumberIsValid-8     0.00B          0.00B          ~     (all equal)

name             old allocs/op  new allocs/op  delta
NumberIsValid-8      0.00           0.00          ~     (all equal)
@gopherbot
Copy link

Change https://go.dev/cl/426134 mentions this issue: encoding/json: optimize isValidNumber by avoiding substring creation in for loop.

@amarjeetanandsingh
Copy link
Contributor Author

@golang golang locked and limited conversation to collaborators Aug 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants