aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-06-24 11:56:55 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-06-24 11:56:55 -0600
commit283c556aa83421c6954a6c0af0358b26c1c7cafa (patch)
tree4550fc51889f26df3d5087714fd917288a5c6ee7
parentMerge pull request #212 from Shopify/stats_sub (diff)
parentreview tweaks (diff)
downloaddedo-283c556aa83421c6954a6c0af0358b26c1c7cafa.tar.gz
dedo-283c556aa83421c6954a6c0af0358b26c1c7cafa.tar.xz
Merge pull request #213 from Shopify/stats_sub2
Drop the *s guard in Stats.Sub()
-rw-r--r--db.go14
1 files changed, 3 insertions, 11 deletions
diff --git a/db.go b/db.go
index d15dc74..2fc9065 100644
--- a/db.go
+++ b/db.go
@@ -575,19 +575,11 @@ type Stats struct {
// This is useful when obtaining stats at two different points and time and
// you need the performance counters that occurred within that time span.
func (s *Stats) Sub(other *Stats) Stats {
- var diff Stats
- if s == nil {
- if other == nil {
- return diff
- } else {
- return *other
- }
- }
- diff = *s
if other == nil {
- return diff
+ return *s
}
- diff.TxN = other.TxN - diff.TxN
+ var diff Stat
+ diff.TxN = other.TxN - s.TxN
diff.TxStats = s.TxStats.Sub(&other.TxStats)
return diff
}