summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/Statistic.h
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2011-10-10 19:48:56 +0000
committerAndrew Trick <atrick@apple.com>2011-10-10 19:48:56 +0000
commit8cc4769108272d309038a657e42b7fcbc5bd94f3 (patch)
tree56c214e75802a8dc49199449975487f26f768545 /include/llvm/ADT/Statistic.h
parentb35e4e84727ff5ba3621b39caa622baef431ca45 (diff)
downloadllvm-8cc4769108272d309038a657e42b7fcbc5bd94f3.tar.gz
llvm-8cc4769108272d309038a657e42b7fcbc5bd94f3.tar.bz2
llvm-8cc4769108272d309038a657e42b7fcbc5bd94f3.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141574 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/Statistic.h')
-rw-r--r--include/llvm/ADT/Statistic.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/llvm/ADT/Statistic.h b/include/llvm/ADT/Statistic.h
index 9bbda986a8..b8a1a2f5c4 100644
--- a/include/llvm/ADT/Statistic.h
+++ b/include/llvm/ADT/Statistic.h
@@ -84,11 +84,13 @@ public:
}
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();
}