perf: refactor to reduce memory allocations and cpu work

This commit is contained in:
Cheong Lau 2025-10-05 16:36:59 +10:00 • committed by Michael Murphy
parent 0c3e3c8629
commit dd0158d8f0
24 changed files with 234 additions and 242 deletions

View file

@ -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(&registry_state, &qh),
toplevel_manager_state: ToplevelManagerState::new(&registry_state, &qh),
queue_handle: qh,
registry_state,
};