-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Using OnceCell to avoid re-compiling regex in multiple invocation of function #76817
Comments
This comment has been minimized.
This comment has been minimized.
Which |
std::lazy::OnceCell is the one to use, yes. |
It now complains that this is not safe to be shared across threads, is a lock worth it? |
Oh, you probably want https://doc.rust-lang.org/nightly/std/lazy/struct.SyncOnceCell.html. |
Yay, it compiles
This |
The Regex::new is only called once in rustc_mir, I don't think we need to introduce macro for it. |
…me, r=ecstatic-morse Don't compile regex at every function call. Use `SyncOnceCell` to only compile it once. I believe this still adds some kind of locking mechanism? Related issue: rust-lang#76817
…me, r=ecstatic-morse Don't compile regex at every function call. Use `SyncOnceCell` to only compile it once. I believe this still adds some kind of locking mechanism? Related issue: rust-lang#76817
…me, r=ecstatic-morse Don't compile regex at every function call. Use `SyncOnceCell` to only compile it once. I believe this still adds some kind of locking mechanism? Related issue: rust-lang#76817
…me, r=ecstatic-morse Don't compile regex at every function call. Use `SyncOnceCell` to only compile it once. I believe this still adds some kind of locking mechanism? Related issue: rust-lang#76817
…me, r=ecstatic-morse Don't compile regex at every function call. Use `SyncOnceCell` to only compile it once. I believe this still adds some kind of locking mechanism? Related issue: rust-lang#76817
…me, r=ecstatic-morse Don't compile regex at every function call. Use `SyncOnceCell` to only compile it once. I believe this still adds some kind of locking mechanism? Related issue: rust-lang#76817
…me, r=ecstatic-morse Don't compile regex at every function call. Use `SyncOnceCell` to only compile it once. I believe this still adds some kind of locking mechanism? Related issue: rust-lang#76817
Fixed. Closing. |
This is debug-only code so it doesn't matter too much in practice, and I'd guess this regex is so small it compiles nearly instantaneously. I wouldn't object to a PR adding a OnceCell if it didn't add too much noise to this code.
Originally posted by #76775 (comment)
The text was updated successfully, but these errors were encountered: