]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Don't needlessly allocate empty counter_updates data in stats_flush()
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 12 May 2014 18:42:33 +0000 (20:42 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 12 May 2014 18:42:33 +0000 (20:42 +0200)
stats.c

diff --git a/stats.c b/stats.c
index 2111b657a31a9c99205fc5b3e66e22fb5dc5e577..d7321265ce6952fc08196cbf9746a17ac010e92e 100644 (file)
--- a/stats.c
+++ b/stats.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2002-2004 Andrew Tridgell
- * Copyright (C) 2009-2011 Joel Rosdahl
+ * Copyright (C) 2009-2014 Joel Rosdahl
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
@@ -200,9 +200,13 @@ stats_flush(void)
        int i;
        extern char *cache_logfile;
 
-       if (getenv("CCACHE_NOSTATS")) return;
+       if (getenv("CCACHE_NOSTATS")) {
+               return;
+       }
 
-       init_counter_updates();
+       if (!counter_updates) {
+               return;
+       }
 
        for (i = 0; i < STATS_END; ++i) {
                if (counter_updates->data[i] > 0) {
@@ -210,7 +214,9 @@ stats_flush(void)
                        break;
                }
        }
-       if (!should_flush) return;
+       if (!should_flush) {
+               return;
+       }
 
        if (!stats_file) {
                char *stats_dir;