Skip to content

Commit

Permalink
Optimise memory allocation in set_webrender_image_key
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Nov 16, 2018
1 parent a5779ad commit da43e35
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions components/net/image_cache.rs
Expand Up @@ -59,6 +59,7 @@ fn set_webrender_image_key(webrender_api: &webrender_api::RenderApi, image: &mut
pixels::rgba8_premultiply_inplace(bytes.as_mut_slice())
},
PixelFormat::RGB8 => {
bytes.reserve(image.bytes.len() / 3 * 4);
for bgr in image.bytes.chunks(3) {
bytes.extend_from_slice(&[bgr[2], bgr[1], bgr[0], 0xff]);
}
Expand Down

0 comments on commit da43e35

Please sign in to comment.