[llvm-commits] [llvm] r141574 - /llvm/trunk/include/llvm/ADT/Statistic.h

Andrew Trick atrick at apple.com
Mon Oct 10 12:48:56 PDT 2011


Author: atrick
Date: Mon Oct 10 14:48:56 2011
New Revision: 141574

URL: http://llvm.org/viewvc/llvm-project?rev=141574&view=rev
Log:
Allow stat += 0 without activating the stat.

For me, this is a nice convenience. We generally want grep to match
stats output only when the event has occurred.

Modified:
    llvm/trunk/include/llvm/ADT/Statistic.h

Modified: llvm/trunk/include/llvm/ADT/Statistic.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Statistic.h?rev=141574&r1=141573&r2=141574&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Statistic.h (original)
+++ llvm/trunk/include/llvm/ADT/Statistic.h Mon Oct 10 14:48:56 2011
@@ -84,11 +84,13 @@
   }
 
   const Statistic &operator+=(const unsigned &V) {
+    if (!V) return *this;
     sys::AtomicAdd(&Value, V);
     return init();
   }
 
   const Statistic &operator-=(const unsigned &V) {
+    if (!V) return *this;
     sys::AtomicAdd(&Value, -V);
     return init();
   }





More information about the llvm-commits mailing list