Merge pull request #213 from Shopify/stats_sub2

Drop the *s guard in Stats.Sub()
master
Ben Johnson 2014-06-24 11:56:55 -06:00
commit 283c556aa8
1 changed files with 3 additions and 11 deletions

14
db.go
View File

@ -575,19 +575,11 @@ type Stats struct {
// This is useful when obtaining stats at two different points and time and // This is useful when obtaining stats at two different points and time and
// you need the performance counters that occurred within that time span. // you need the performance counters that occurred within that time span.
func (s *Stats) Sub(other *Stats) Stats { 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 { 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) diff.TxStats = s.TxStats.Sub(&other.TxStats)
return diff return diff
} }