mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
refactor: change function definitions to const for improved performance and clarity
This commit is contained in:
@@ -45,7 +45,7 @@ enum Operation {
|
||||
}
|
||||
|
||||
impl Operation {
|
||||
fn timeout(&self) -> u64 {
|
||||
const fn timeout(&self) -> u64 {
|
||||
match self {
|
||||
Self::Upload => TIMEOUT_UPLOAD,
|
||||
Self::Download => TIMEOUT_DOWNLOAD,
|
||||
|
||||
@@ -84,7 +84,7 @@ impl fmt::Display for SystemHotkey {
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
impl SystemHotkey {
|
||||
pub fn function(self) -> HotkeyFunction {
|
||||
pub const fn function(self) -> HotkeyFunction {
|
||||
match self {
|
||||
Self::CmdQ => HotkeyFunction::Quit,
|
||||
Self::CmdW => HotkeyFunction::Hide,
|
||||
|
||||
@@ -137,7 +137,7 @@ impl CoreManager {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_connection_io_error(kind: std::io::ErrorKind) -> bool {
|
||||
const fn is_connection_io_error(kind: std::io::ErrorKind) -> bool {
|
||||
matches!(
|
||||
kind,
|
||||
std::io::ErrorKind::ConnectionAborted
|
||||
|
||||
@@ -449,7 +449,7 @@ impl ServiceManager {
|
||||
Self(ServiceStatus::Unavailable("Need Checks".into()))
|
||||
}
|
||||
|
||||
pub fn config() -> Option<clash_verge_service_ipc::IpcConfig> {
|
||||
pub const fn config() -> Option<clash_verge_service_ipc::IpcConfig> {
|
||||
Some(clash_verge_service_ipc::IpcConfig {
|
||||
default_timeout: Duration::from_millis(30),
|
||||
retry_delay: Duration::from_millis(250),
|
||||
|
||||
@@ -16,7 +16,7 @@ pub struct CoreConfigValidator {
|
||||
}
|
||||
|
||||
impl CoreConfigValidator {
|
||||
pub fn new() -> Self {
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
is_processing: AtomicBool::new(false),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user