mirror of
https://github.com/etcd-io/bbolt.git
synced 2025-05-31 11:42:30 +00:00
add some guards for nil pointers
This commit is contained in:
parent
bbee09da30
commit
32e22b3bb6
11
db.go
11
db.go
@ -575,8 +575,15 @@ 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 = *s
|
||||
diff.TxN = other.TxN - s.TxN
|
||||
var diff Stats
|
||||
if s == nil {
|
||||
return diff
|
||||
}
|
||||
diff = *s
|
||||
if other == nil {
|
||||
return diff
|
||||
}
|
||||
diff.TxN = other.TxN - diff.TxN
|
||||
diff.TxStats = s.TxStats.Sub(&other.TxStats)
|
||||
return diff
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user