Refactor an if statement

This commit is contained in:
Josh Holmer 2018-01-30 22:27:34 -05:00
parent 348c7dbc56
commit 0c2e3777b1

View file

@ -271,19 +271,13 @@ impl PngData {
for line in self.scan_lines() { for line in self.scan_lines() {
match filter { match filter {
0 | 1 | 2 | 3 | 4 => { 0 | 1 | 2 | 3 | 4 => {
if last_pass == line.pass || filter <= 1 { let filter = if last_pass == line.pass || filter <= 1 {
filtered.push(filter); filter
filtered.extend_from_slice(&filter_line(
filter,
bpp,
&line.data,
&last_line,
));
} else { } else {
// Avoid vertical filtering on first line of each interlacing pass 0
filtered.push(0); };
filtered.extend_from_slice(&filter_line(0, bpp, &line.data, &last_line)); filtered.push(filter);
} filtered.extend_from_slice(&filter_line(filter, bpp, &line.data, &last_line));
} }
5 => { 5 => {
// Heuristically guess best filter per line // Heuristically guess best filter per line