Skip to content

Commit

Permalink
types: avoid using defer unlock in CopyDepth
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Jan 24, 2024
1 parent 6cf5300 commit 805fea3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pkg/types/orderbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,25 @@ func (b *MutexOrderBook) Reset() {
b.Unlock()
}

func (b *MutexOrderBook) CopyDepth(depth int) OrderBook {
func (b *MutexOrderBook) CopyDepth(depth int) (ob OrderBook) {
b.Lock()
defer b.Unlock()

return b.orderBook.CopyDepth(depth)
ob = b.orderBook.CopyDepth(depth)
b.Unlock()
return ob
}

func (b *MutexOrderBook) Copy() OrderBook {
func (b *MutexOrderBook) Copy() (ob OrderBook) {
b.Lock()
defer b.Unlock()
ob = b.orderBook.Copy()
b.Unlock()

return b.orderBook.Copy()
return ob
}

func (b *MutexOrderBook) Update(update SliceOrderBook) {
b.Lock()
defer b.Unlock()

b.orderBook.Update(update)
b.Unlock()
}

type BookSignalType string
Expand Down

0 comments on commit 805fea3

Please sign in to comment.