]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
enhance: Short circuit StatisticsCounters::increment for zero value
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 5 Sep 2022 11:17:26 +0000 (13:17 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 6 Sep 2022 06:13:28 +0000 (08:13 +0200)
src/core/StatisticsCounters.cpp

index 5bef8438343b74354060d8bd6525bf072f0308eb..3f1f2d6568790e71987748bb46900f95595fde66 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2021 Joel Rosdahl and other contributors
+// Copyright (C) 2010-2022 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -78,6 +78,9 @@ StatisticsCounters::set_raw(size_t index, uint64_t value)
 void
 StatisticsCounters::increment(Statistic statistic, int64_t value)
 {
+  if (value == 0) {
+    return;
+  }
   const auto i = static_cast<size_t>(statistic);
   if (i >= m_counters.size()) {
     m_counters.resize(i + 1);