Skip to content

Commit

Permalink
convert_js_image_to_luma: estimate vec capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Feb 7, 2024
1 parent 0d01ec9 commit e4ad28c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ pub fn decode_barcode(
/// Such an object could be obtained using the `getImageData`
/// method of a `CanvasRenderingContext2D` object.
pub fn convert_js_image_to_luma(data: &[u8]) -> Vec<u8> {
let mut luma_data = Vec::new();
let mut luma_data = Vec::with_capacity(data.len() / 4);
for src_pixel in data.chunks_exact(4) {
let [red, green, blue, alpha] = src_pixel else {
continue;
Expand Down

0 comments on commit e4ad28c

Please sign in to comment.