perf: refactor to reduce memory allocations and cpu work
This commit is contained in:
parent
0c3e3c8629
commit
dd0158d8f0
24 changed files with 234 additions and 242 deletions
|
|
@ -173,7 +173,7 @@ impl cosmic::Application for Minimize {
|
|||
// Temporarily take ownership to appease the borrow checker.
|
||||
let mut apps = std::mem::take(&mut self.apps);
|
||||
|
||||
if let Some(pos) = apps.iter_mut().position(|a| {
|
||||
if let Some(pos) = apps.iter().position(|a| {
|
||||
a.toplevel_info.foreign_toplevel == toplevel_info.foreign_toplevel
|
||||
}) {
|
||||
if apps[pos].toplevel_info.app_id != toplevel_info.app_id {
|
||||
|
|
@ -194,7 +194,7 @@ impl cosmic::Application for Minimize {
|
|||
name: desktop_entry
|
||||
.full_name(&self.locales)
|
||||
.unwrap_or(Cow::Borrowed(&desktop_entry.appid))
|
||||
.to_string(),
|
||||
.into_owned(),
|
||||
icon_source: fde::IconSource::from_unknown(
|
||||
desktop_entry.icon().unwrap_or(&desktop_entry.appid),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ impl<T: AsFd> ShmImage<T> {
|
|||
pub fn image(&self) -> anyhow::Result<image::RgbaImage> {
|
||||
let mmap = unsafe { memmap2::Mmap::map(&self.fd.as_fd())? };
|
||||
image::RgbaImage::from_raw(self.width, self.height, mmap.to_vec())
|
||||
.ok_or(anyhow::anyhow!("ShmImage had incorrect size"))
|
||||
.ok_or_else(|| anyhow::anyhow!("ShmImage had incorrect size"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -475,12 +475,12 @@ pub(crate) fn wayland_handler(
|
|||
exit: false,
|
||||
tx,
|
||||
conn,
|
||||
queue_handle: qh.clone(),
|
||||
shm_state,
|
||||
screencopy_state,
|
||||
seat_state: SeatState::new(&globals, &qh),
|
||||
toplevel_info_state: ToplevelInfoState::new(®istry_state, &qh),
|
||||
toplevel_manager_state: ToplevelManagerState::new(®istry_state, &qh),
|
||||
queue_handle: qh,
|
||||
registry_state,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue