mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
fix: optimize process ID collection and remove unnecessary async handler in window destruction
fix: remove unnecessary condition check in process name matching
This commit is contained in:
@@ -83,7 +83,7 @@ impl CoreManager {
|
|||||||
|
|
||||||
let process_name_clone = process_name.clone();
|
let process_name_clone = process_name.clone();
|
||||||
let pids = AsyncHandler::spawn_blocking(move || -> Result<Vec<u32>> {
|
let pids = AsyncHandler::spawn_blocking(move || -> Result<Vec<u32>> {
|
||||||
let mut pids = Vec::with_capacity(8);
|
let mut pids = Vec::new();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
let snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||||
@@ -102,12 +102,10 @@ impl CoreManager {
|
|||||||
.position(|&x| x == 0)
|
.position(|&x| x == 0)
|
||||||
.unwrap_or(pe32.szExeFile.len());
|
.unwrap_or(pe32.szExeFile.len());
|
||||||
|
|
||||||
if end_pos > 0 {
|
|
||||||
let exe_file = String::from_utf16_lossy(&pe32.szExeFile[..end_pos]);
|
let exe_file = String::from_utf16_lossy(&pe32.szExeFile[..end_pos]);
|
||||||
if exe_file.eq_ignore_ascii_case(&process_name_clone) {
|
if exe_file.eq_ignore_ascii_case(&process_name_clone) {
|
||||||
pids.push(pe32.th32ProcessID);
|
pids.push(pe32.th32ProcessID);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if Process32NextW(snapshot, &mut pe32) == 0 {
|
if Process32NextW(snapshot, &mut pe32) == 0 {
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -339,13 +339,6 @@ pub fn run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_window_destroyed() {
|
pub fn handle_window_destroyed() {
|
||||||
AsyncHandler::spawn(|| async {
|
|
||||||
let _ = handle::Handle::mihomo()
|
|
||||||
.await
|
|
||||||
.clear_all_ws_connections()
|
|
||||||
.await;
|
|
||||||
});
|
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
use crate::core::hotkey::SystemHotkey;
|
use crate::core::hotkey::SystemHotkey;
|
||||||
|
|||||||
Reference in New Issue
Block a user