Preallocate memory in reduced_alpha_to_up (#180)
This commit is contained in:
parent
56b94542a6
commit
34ee78dbbc
1 changed files with 2 additions and 2 deletions
|
|
@ -93,11 +93,11 @@ fn reduced_alpha_to_white(png: &PngImage, bpc: usize, bpp: usize) -> Vec<u8> {
|
|||
}
|
||||
|
||||
fn reduced_alpha_to_up(png: &PngImage, bpc: usize, bpp: usize) -> Vec<u8> {
|
||||
let mut lines = Vec::new();
|
||||
let mut scan_lines = png.scan_lines().collect::<Vec<ScanLine<'_>>>();
|
||||
scan_lines.reverse();
|
||||
let mut lines = Vec::with_capacity(scan_lines.len());
|
||||
let mut last_line = Vec::new();
|
||||
let mut current_line = Vec::with_capacity(last_line.len());
|
||||
let mut current_line = Vec::with_capacity(scan_lines[0].data.len() + 1); // filter size + pixels
|
||||
for line in scan_lines {
|
||||
if line.data.len() != last_line.len() {
|
||||
last_line = vec![0; line.data.len()];
|
||||
|
|
|
|||
Loading…
Reference in a new issue