Skip to content

Commit

Permalink
fix(PNG encoding): Return early if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Aug 31, 2021
1 parent 07e33a9 commit 6cd52a9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rust/src/methods/encode/png.rs
Expand Up @@ -14,6 +14,11 @@ pub async fn encode(node: &Node, output: &str, options: Option<Options>) -> Resu

/// Encode a list of `Node`s to PNGs (as bytes)
pub async fn encode_to_pngs(nodes: &[&Node], options: Option<Options>) -> Result<Vec<Vec<u8>>> {
// Return early if possible to avoid the following, including requiring Chrome.
if nodes.is_empty() {
return Ok(Vec::new())
}

// Generate HTML for each node
let mut html = String::new();
for (index, node) in nodes.iter().enumerate() {
Expand Down

0 comments on commit 6cd52a9

Please sign in to comment.