aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-06-24 11:37:16 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-06-24 11:37:16 -0600
commit78d08e0438f55eaee5f26e4599890926ac48205f (patch)
treef40eccfc4c414982f7c02168043ea4c602087887
parentMerge pull request #210 from benbjohnson/default-options (diff)
parentreview tweaks (diff)
downloaddedo-78d08e0438f55eaee5f26e4599890926ac48205f.tar.gz
dedo-78d08e0438f55eaee5f26e4599890926ac48205f.tar.xz
Merge pull request #212 from Shopify/stats_sub
Improve Stats.Sub()
-rw-r--r--db.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/db.go b/db.go
index 6ec07a7..d15dc74 100644
--- a/db.go
+++ b/db.go
@@ -576,6 +576,18 @@ type Stats struct {
// 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
+ }
+ diff.TxN = other.TxN - diff.TxN
diff.TxStats = s.TxStats.Sub(&other.TxStats)
return diff
}