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

Lazily initialize regexes to speed up init() #1277

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

kylecarbs
Copy link
Contributor

Using GODEBUG=inittrace=1 I found a relatively constant 10ms init caused by this function.

Replaces #1246.

@go-playground/validator-maintainers

Using `GODEBUG=inittrace=1` I found a relatively constant 10ms init caused by this function.

Replaces go-playground#1246.
@kylecarbs kylecarbs requested a review from a team as a code owner June 11, 2024 12:33
@kylecarbs
Copy link
Contributor Author

@deankarn sorry for the PR spam, other one automatically closed! 🤦

I changed this to use sync.Once, which I agree is cleaner.

@coveralls
Copy link

Coverage Status

coverage: 74.272% (+0.02%) from 74.257%
when pulling 9ded6c5 on kylecarbs:master
into c7e8518 on go-playground:master.

@kylecarbs kylecarbs changed the title Lazily initialize regexes to speed up `init() Lazily initialize regexes to speed up init() Jun 11, 2024
@deankarn deankarn merged commit 2e1df48 into go-playground:master Jun 12, 2024
15 checks passed
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.

None yet

3 participants