Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Nov 3, 2023
1 parent e9a4f9e commit 8180276
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
15 changes: 6 additions & 9 deletions benches/process.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use criterion::{criterion_group, criterion_main, Criterion};
#[cfg(windows)]
use mitmproxy::windows::{icons, processes};
#[cfg(target_os = "macos")]
use mitmproxy::macos::icons;
#[cfg(windows)]
use mitmproxy::windows::{icons, processes};

#[cfg(windows)]
use windows::Win32::System::LibraryLoader::GetModuleHandleW;
Expand Down Expand Up @@ -49,7 +49,9 @@ fn criterion_benchmark(c: &mut Criterion) {
}
#[cfg(target_os = "macos")]
{
let test_app = std::path::PathBuf::from("/System/Library/CoreServices/Finder.app/Contents/MacOS/Finder");
let test_app = std::path::PathBuf::from(
"/System/Library/CoreServices/Finder.app/Contents/MacOS/Finder",
);

c.bench_function("get png with system", |b| {
b.iter(|| {
Expand All @@ -59,17 +61,12 @@ fn criterion_benchmark(c: &mut Criterion) {
})
});


let mut cache = icons::IconCache::default();
c.bench_function("get_png with system", |b| {
b.iter(|| {
cache
.get_png(test_app.clone())
.unwrap();
cache.get_png(test_app.clone()).unwrap();
})
});


}
}

Expand Down
4 changes: 1 addition & 3 deletions src/macos/icons.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::{bail, Result};
use cocoa::base::id;
use image::ImageEncoder;
use objc::{class, msg_send, sel, sel_impl};
use once_cell::sync::Lazy;
use std::collections::hash_map::DefaultHasher;
Expand All @@ -9,7 +10,6 @@ use std::path::Path;
use std::path::PathBuf;
use std::{collections::hash_map::Entry, sync::Mutex};
use sysinfo::{PidExt, ProcessExt, ProcessRefreshKind, System, SystemExt};
use image::ImageEncoder;

pub static ICON_CACHE: Lazy<Mutex<IconCache>> = Lazy::new(|| Mutex::new(IconCache::default()));

Expand All @@ -22,7 +22,6 @@ pub struct IconCache {
}

impl IconCache {

pub fn get_png(&mut self, executable: PathBuf) -> Result<&Vec<u8>> {
match self.executables.entry(executable) {
Entry::Occupied(e) => {
Expand All @@ -41,7 +40,6 @@ impl IconCache {
}
}
}

}

pub fn tif_to_png(tif: &[u8]) -> Result<Vec<u8>> {
Expand Down

0 comments on commit 8180276

Please sign in to comment.