From 701bcd63d27ab7faa9edaedd8efc20c44e4d9552 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Mon, 12 May 2014 20:42:33 +0200 Subject: [PATCH] Don't needlessly allocate empty counter_updates data in stats_flush() --- stats.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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; -- 2.47.2