yagit

Yet another static site generator for Git 🙀️

Commit
233a1e57c2236677ae9aefd48f87073b78e8cb0c
Parent
98ee25f2cf656060d36c1afd6089bdafde29387d
Author
Pablo <pablo-pie@riseup.net>
Date

Removed unecessary calls

Removed unecessary calls to Diff::stats when processing commits which should be skiped

Diffstats

1 files changed, 5 insertions, 2 deletions

Status Name Changes Insertions Deletions
Modified src/main.rs 2 files changed 5 2
diff --git a/src/main.rs b/src/main.rs
@@ -815,7 +815,6 @@ impl<'repo> RepoRenderer<'repo> {
         commit.tree().ok().as_ref(),
         None
       ).expect("diff between trees should be there");
-    let stats = diff.stats().expect("should be able to accumulate stats");
 
     let deltas_iter = diff.deltas();
     let mut deltas: Vec<DeltaInfo<'_>> = Vec::with_capacity(deltas_iter.len());
@@ -890,12 +889,16 @@ impl<'repo> RepoRenderer<'repo> {
     }
 
     // ========================================================================
-
     // skip rendering the commit page if the file already exists
     if should_skip {
       return Ok(());
     }
 
+    // NOTE: this is an expensive operation, taking upwards of 76% of
+    //       execution-time: Diff::stats should only be called when we
+    //       know for the page needs updating
+    let stats = diff.stats().expect("should be able to accumulate stats");
+
     let mut f = match File::create(&path) {
       Ok(f)  => f,
       Err(e) => {