]> git.armaanb.net Git - stagit.git/commitdiff
performance tweak: check if commit file exists, if so skip
authorHiltjo Posthuma <hiltjo@codemadness.org>
Mon, 7 Dec 2015 20:34:53 +0000 (21:34 +0100)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Mon, 7 Dec 2015 20:34:53 +0000 (21:34 +0100)
urmoms.c

index 5e10a2ff2d923780b393c82be1ec6d0614c47275..159e095c48ab364fd38526082f930438500d8ca2 100644 (file)
--- a/urmoms.c
+++ b/urmoms.c
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "git2.h"
 
@@ -218,10 +219,13 @@ printshowfile(git_commit *commit)
 
        git_oid_tostr(buf, sizeof(buf), git_commit_id(commit));
        snprintf(path, sizeof(path), "commit/%s.html", buf);
-       fp = efopen(path, "w+b");
+       /* check if file exists if so skip it */
+       if (!access(path, F_OK))
+               return;
 
        memset(&diffstatsbuf, 0, sizeof(diffstatsbuf));
 
+       fp = efopen(path, "w+b");
        writeheader(fp);
        printcommit(fp, commit);