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

Replace lazy_static with std::sync::OnceLock #301

Merged
merged 2 commits into from
Dec 29, 2023
Merged

Conversation

serprex
Copy link
Contributor

@serprex serprex commented Dec 25, 2023

once_cell is preferred over lazy_static: rust-lang-nursery/lazy-static.rs#214

@jxs
Copy link
Member

jxs commented Dec 27, 2023

Hi, and thanks for this! I think we can even use OnceCell or OnceLock as they have been added to std and drop any external dependency for this, wdyt?

@serprex
Copy link
Contributor Author

serprex commented Dec 27, 2023

Given your MSRV policy, that works. It'll also be a much more impacting change, I'm thinking RE will be made private & a function will return reference to shared regex. In the case of runner.rs that's already almost done with file_match_re

@serprex
Copy link
Contributor Author

serprex commented Dec 27, 2023

Reading more closely, one of the REs were unused. For finding migration files there's now a match to decide whether to construct regex for rs or sql|rs. I imagine this isn't a case where constructing regex needs to be optimized so much, otherwise the two regexen could have their own OnceLock which the match would select & no format would be involved

@serprex serprex changed the title Replace lazy_static with once_cell Replace lazy_static with std::sync::OnceLock Dec 27, 2023
Copy link
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

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

Thanks! ❤️

@jxs jxs merged commit 3a4a22b into rust-db:main Dec 29, 2023
27 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.

2 participants