]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Fix regression in b81df8bf of "cache hit rate" statistics output
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 29 Jul 2016 16:24:28 +0000 (18:24 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 29 Jul 2016 16:26:45 +0000 (18:26 +0200)
stats.c

diff --git a/stats.c b/stats.c
index 3a69ddb290ccafb6f7ed241799556b8b5ea0746f..6eff3e1ec5992e74206ca2386c10c17cf11fac1b 100644 (file)
--- a/stats.c
+++ b/stats.c
@@ -305,15 +305,11 @@ stats_summary(struct conf *conf)
                        printf("%8u\n", counters->data[stat]);
                }
 
-               unsigned direct = 0;
-               unsigned preprocessed = 0;
-               if (stat == STATS_CACHEHIT_DIR) {
-                       direct = counters->data[stat];
-               } else if (stat == STATS_CACHEHIT_CPP) {
-                       preprocessed = counters->data[stat];
-               } else if (stat == STATS_TOCACHE) {
-                       unsigned miss = counters->data[stat];
+               if (stat == STATS_TOCACHE) {
+                       unsigned direct = counters->data[STATS_CACHEHIT_DIR];
+                       unsigned preprocessed = counters->data[STATS_CACHEHIT_CPP];
                        unsigned hit = direct + preprocessed;
+                       unsigned miss = counters->data[STATS_TOCACHE];
                        unsigned total = hit + miss;
                        double percent = total > 0 ? (100.0f * hit) / total : 0.0f;
                        printf("cache hit rate                    %6.2f %%\n", percent);