-
Notifications
You must be signed in to change notification settings - Fork 349
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
Use std LazyLock instead of once_cell Lazy #6529
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status: 0 of 52 files reviewed, 1 unresolved discussion (waiting on @dlon)
talpid-core/src/firewall/linux.rs
line 62 at r1 (raw file):
LazyLock::new(|| CString::new("prerouting").unwrap()); static MANGLE_CHAIN_NAME: LazyLock<CString> = LazyLock::new(|| CString::new("mangle").unwrap()); static NAT_CHAIN_NAME: LazyLock<CString> = LazyLock::new(|| CString::new("nat").unwrap());
Nit: I think these uses of LazyLock
could fairly easily be replaced by swapping to &CStr
static TABLE_NAME: &CStr = c"mullvad";
static IN_CHAIN_NAME: &CStr = c"input";
static OUT_CHAIN_NAME: &CStr = c"output";
static FORWARD_CHAIN_NAME: &CStr = c"forward";
static PREROUTING_CHAIN_NAME: &CStr = c"prerouting";
static MANGLE_CHAIN_NAME: &CStr = c"mangle";
static NAT_CHAIN_NAME: &CStr = c"nat";
Might apply for other uses of static CString
s as well
Code quote:
static TABLE_NAME: LazyLock<CString> = LazyLock::new(|| CString::new("mullvad").unwrap());
static IN_CHAIN_NAME: LazyLock<CString> = LazyLock::new(|| CString::new("input").unwrap());
static OUT_CHAIN_NAME: LazyLock<CString> = LazyLock::new(|| CString::new("output").unwrap());
static FORWARD_CHAIN_NAME: LazyLock<CString> = LazyLock::new(|| CString::new("forward").unwrap());
static PREROUTING_CHAIN_NAME: LazyLock<CString> =
LazyLock::new(|| CString::new("prerouting").unwrap());
static MANGLE_CHAIN_NAME: LazyLock<CString> = LazyLock::new(|| CString::new("mangle").unwrap());
static NAT_CHAIN_NAME: LazyLock<CString> = LazyLock::new(|| CString::new("nat").unwrap());
a57e37f
to
6d4a301
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 54 files reviewed, all discussions resolved
talpid-core/src/firewall/linux.rs
line 62 at r1 (raw file):
Previously, MarkusPettersson98 (Markus Pettersson) wrote…
Nit: I think these uses of
LazyLock
could fairly easily be replaced by swapping to&CStr
static TABLE_NAME: &CStr = c"mullvad"; static IN_CHAIN_NAME: &CStr = c"input"; static OUT_CHAIN_NAME: &CStr = c"output"; static FORWARD_CHAIN_NAME: &CStr = c"forward"; static PREROUTING_CHAIN_NAME: &CStr = c"prerouting"; static MANGLE_CHAIN_NAME: &CStr = c"mangle"; static NAT_CHAIN_NAME: &CStr = c"nat";Might apply for other uses of static
CString
s as well
Great idea!
5a9ef35
to
26fc4f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 27 of 52 files at r1, 31 of 31 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dlon)
talpid-wireguard/src/lib.rs
line 16 at r2 (raw file):
use std::io; #[cfg(target_os = "linux")] use std::sync::LazyLock;
Nit The Linux-specific imports could be grouped to reduce visual clutter a bit
#[cfg(target_os = "linux")]
use std::{env, sync::LazyLock};
#[cfg(windows)]
use std::io;
Code quote:
#[cfg(target_os = "linux")]
use std::env;
#[cfg(windows)]
use std::io;
#[cfg(target_os = "linux")]
use std::sync::LazyLock;
26fc4f2
to
c6ca867
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved
c6ca867
to
cd409ea
Compare
The container needs to be updated to use Rust 1.80 before this can be merged.
This change is