Skip to content

Commit

Permalink
Use rayon when serializing glyphs
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyr committed Jul 29, 2021
1 parent 44778cb commit 654582f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,16 @@ impl Layer {
if !self.layerinfo_is_empty() {
self.layerinfo_to_file(path)?;
}
for (name, glyph_path) in self.contents.iter() {
let glyph = self.glyphs.get(name).expect("all glyphs in contents must exist.");
glyph.save(path.join(glyph_path))?;
}

Ok(())
#[cfg(feature = "rayon")]
let iter = self.contents.par_iter();
#[cfg(not(feature = "rayon"))]
let mut iter = self.contents.iter();

iter.try_for_each(|(name, glyph_path)| {
let glyph = self.glyphs.get(name).expect("all glyphs in contents must exist.");
glyph.save(path.join(glyph_path))
})
}

/// The number of [`Glyph`]s in the layer.
Expand Down

0 comments on commit 654582f

Please sign in to comment.