Optimisation: Large struct pointer conversion (final part) (#265)

Completes large struct pointer optomisations over the entire codebase and enables hugeParams linter by default
This commit is contained in:
Andrew
2019-04-04 15:31:49 +11:00
committed by Adrian Gallagher
parent 107cf76373
commit ca55f2f965
97 changed files with 195 additions and 195 deletions

View File

@@ -137,7 +137,7 @@ func QuoteCurrencyExists(exchange string, p currency.Pair) bool {
}
// CreateNewOrderbook creates a new orderbook
func CreateNewOrderbook(exchangeName string, orderbookNew Base, orderbookType string) *Orderbook {
func CreateNewOrderbook(exchangeName string, orderbookNew *Base, orderbookType string) *Orderbook {
m.Lock()
defer m.Unlock()
orderbook := Orderbook{}
@@ -145,7 +145,7 @@ func CreateNewOrderbook(exchangeName string, orderbookNew Base, orderbookType st
orderbook.Orderbook = make(map[*currency.Item]map[*currency.Item]map[string]Base)
a := make(map[*currency.Item]map[string]Base)
b := make(map[string]Base)
b[orderbookType] = orderbookNew
b[orderbookType] = *orderbookNew
a[orderbookNew.Pair.Quote.Item] = b
orderbook.Orderbook[orderbookNew.Pair.Base.Item] = a
Orderbooks = append(Orderbooks, orderbook)
@@ -154,7 +154,7 @@ func CreateNewOrderbook(exchangeName string, orderbookNew Base, orderbookType st
// Process processes incoming orderbooks, creating or updating the orderbook
// list
func (o Base) Process() error {
func (o *Base) Process() error {
if o.Pair.IsEmpty() {
return errors.New("orderbook currency pair not populated")
}
@@ -176,7 +176,7 @@ func (o Base) Process() error {
if BaseCurrencyExists(o.ExchangeName, o.Pair.Base) {
m.Lock()
a := make(map[string]Base)
a[o.AssetType] = o
a[o.AssetType] = *o
orderbook.Orderbook[o.Pair.Base.Item][o.Pair.Quote.Item] = a
m.Unlock()
return nil
@@ -185,7 +185,7 @@ func (o Base) Process() error {
m.Lock()
a := make(map[*currency.Item]map[string]Base)
b := make(map[string]Base)
b[o.AssetType] = o
b[o.AssetType] = *o
a[o.Pair.Quote.Item] = b
orderbook.Orderbook[o.Pair.Base.Item] = a
m.Unlock()

View File

@@ -79,7 +79,7 @@ func TestGetOrderbook(t *testing.T) {
Bids: []Item{{Price: 200, Amount: 10}},
}
CreateNewOrderbook("Exchange", base, Spot)
CreateNewOrderbook("Exchange", &base, Spot)
result, err := Get("Exchange", c, Spot)
if err != nil {
@@ -116,7 +116,7 @@ func TestGetOrderbookByExchange(t *testing.T) {
Bids: []Item{{Price: 200, Amount: 10}},
}
CreateNewOrderbook("Exchange", base, Spot)
CreateNewOrderbook("Exchange", &base, Spot)
_, err := GetByExchange("Exchange")
if err != nil {
@@ -138,7 +138,7 @@ func TestFirstCurrencyExists(t *testing.T) {
Bids: []Item{{Price: 200, Amount: 10}},
}
CreateNewOrderbook("Exchange", base, Spot)
CreateNewOrderbook("Exchange", &base, Spot)
if !BaseCurrencyExists("Exchange", c.Base) {
t.Fatal("Test failed. TestFirstCurrencyExists expected first currency doesn't exist")
@@ -158,7 +158,7 @@ func TestSecondCurrencyExists(t *testing.T) {
Bids: []Item{{Price: 200, Amount: 10}},
}
CreateNewOrderbook("Exchange", base, Spot)
CreateNewOrderbook("Exchange", &base, Spot)
if !QuoteCurrencyExists("Exchange", c) {
t.Fatal("Test failed. TestSecondCurrencyExists expected first currency doesn't exist")
@@ -178,7 +178,7 @@ func TestCreateNewOrderbook(t *testing.T) {
Bids: []Item{{Price: 200, Amount: 10}},
}
CreateNewOrderbook("Exchange", base, Spot)
CreateNewOrderbook("Exchange", &base, Spot)
result, err := Get("Exchange", c, Spot)
if err != nil {