Skip to content

Commit 772262f

Browse files
committed
perf: avoid copying when creating WaylandImage
1 parent 16d0a0c commit 772262f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cosmic-app-list/src/wayland_subscription.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ pub struct WaylandImage {
5757

5858
impl WaylandImage {
5959
pub fn new(img: image::RgbaImage) -> Self {
60+
let width = img.width();
61+
let height = img.height();
62+
6063
Self {
61-
// TODO avoid copy?
62-
img: Bytes::copy_from_slice(img.as_bytes()),
63-
width: img.width(),
64-
height: img.height(),
64+
img: Bytes::from_owner(img.into_vec()),
65+
width,
66+
height,
6567
}
6668
}
6769
}

0 commit comments

Comments
 (0)