Skip to content

Commit

Permalink
Fix a change that breaks itertools with newer versions of Rust nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
shssoichiro committed Mar 5, 2018
1 parent 88636d2 commit d736970
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 45 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### Version 1.0.2
- Fix a change that breaks Itertools::flatten with recent Rust nightlies

### Version 1.0.1
- Bump rayon to 1.0 ([#99](https://github.com/shssoichiro/oxipng/pull/99) @cuviper)
- Bump minor versions of other dependencies for binary distribution
Expand Down
64 changes: 32 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ homepage = "https://github.com/shssoichiro/oxipng"
license = "MIT"
name = "oxipng"
repository = "https://github.com/shssoichiro/oxipng"
version = "1.0.1"
version = "1.0.2"

[badges]
travis-ci = { repository = "shssoichiro/oxipng", branch = "master" }
Expand All @@ -30,7 +30,7 @@ bit-vec = "^0.4.2"
byteorder = "^1.0.0"
crc = "^1.2.0"
glob = "0.2.11"
itertools = "^0.7.0"
itertools = "^0.7.7"
num_cpus = "^1.0.0"
rayon = "^1.0.0"
zopfli = "^0.3.4"
Expand Down
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ impl Default for Options {
pub fn optimize(input_path: &Path, opts: &Options) -> Result<(), PngError> {
// Initialize the thread pool with correct number of threads
let thread_count = opts.threads;
let _ = rayon::ThreadPoolBuilder::new().num_threads(thread_count).build_global();
let _ = rayon::ThreadPoolBuilder::new()
.num_threads(thread_count)
.build_global();

// Read in the file and try to decode as PNG.
if opts.verbosity.is_some() {
Expand Down Expand Up @@ -351,7 +353,9 @@ pub fn optimize(input_path: &Path, opts: &Options) -> Result<(), PngError> {
pub fn optimize_from_memory(data: &[u8], opts: &Options) -> Result<Vec<u8>, PngError> {
// Initialize the thread pool with correct number of threads
let thread_count = opts.threads;
let _ = rayon::ThreadPoolBuilder::new().num_threads(thread_count).build_global();
let _ = rayon::ThreadPoolBuilder::new()
.num_threads(thread_count)
.build_global();

// Read in the file and try to decode as PNG.
if opts.verbosity.is_some() {
Expand Down
15 changes: 6 additions & 9 deletions src/png/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use error::PngError;
use filters::*;
use headers::*;
use interlace::{deinterlace_image, interlace_image};
use itertools::Itertools;
use itertools::{flatten, Itertools};
use reduction::bit_depth::*;
use reduction::color::*;
use std::collections::{HashMap, HashSet};
Expand Down Expand Up @@ -138,7 +138,7 @@ impl PngData {
let mut png_data = PngData {
idat_data: idat_headers,
ihdr_data: ihdr_header,
raw_data: raw_data,
raw_data,
palette: aux_headers.remove("PLTE"),
transparency_pixel: if has_transparency_pixel {
aux_headers.remove("tRNS")
Expand All @@ -150,7 +150,7 @@ impl PngData {
} else {
None
},
aux_headers: aux_headers,
aux_headers,
};
png_data.raw_data = png_data.unfilter_image();
// Return the PngData
Expand Down Expand Up @@ -551,10 +551,7 @@ impl PngData {
}
index_map.clear();
self.raw_data = new_data;
let new_palette = indexed_palette
.iter()
.cloned()
.flatten()
let new_palette = flatten(indexed_palette.iter().cloned())
.enumerate()
.filter(|&(i, _)| !(self.transparency_palette.is_some() && i % 4 == 3))
.map(|(_, x)| *x)
Expand Down Expand Up @@ -726,7 +723,7 @@ impl PngData {
lines.push(current_line.clone());
current_line.clear();
}
lines.into_iter().rev().flatten().collect()
flatten(lines.into_iter().rev()).collect()
}

fn reduce_alpha_to_down(&self, bpc: usize, bpp: usize) -> Vec<u8> {
Expand Down Expand Up @@ -766,7 +763,7 @@ impl PngData {
last_pixel = pixel.to_owned();
}
reduced.push(line.filter);
reduced.extend(line_bytes.chunks(bpp).rev().flatten());
reduced.extend(flatten(line_bytes.chunks(bpp).rev()));
}
reduced
}
Expand Down

0 comments on commit d736970

Please sign in to comment.