From: Joel Rosdahl Date: Mon, 12 May 2014 18:42:33 +0000 (+0200) Subject: Don't needlessly allocate empty counter_updates data in stats_flush() X-Git-Tag: v3.1.10~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=701bcd63d27ab7faa9edaedd8efc20c44e4d9552;p=thirdparty%2Fccache.git Don't needlessly allocate empty counter_updates data in stats_flush() --- diff --git a/stats.c b/stats.c index 2111b657a..d7321265c 100644 --- 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;