Skip to content

Commit e4ad28c

Browse files
committed
convert_js_image_to_luma: estimate vec capacity
1 parent 0d01ec9 commit e4ad28c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ pub fn decode_barcode(
325325
/// Such an object could be obtained using the `getImageData`
326326
/// method of a `CanvasRenderingContext2D` object.
327327
pub fn convert_js_image_to_luma(data: &[u8]) -> Vec<u8> {
328-
let mut luma_data = Vec::new();
328+
let mut luma_data = Vec::with_capacity(data.len() / 4);
329329
for src_pixel in data.chunks_exact(4) {
330330
let [red, green, blue, alpha] = src_pixel else {
331331
continue;

0 commit comments

Comments
 (0)