Просмотр исходного кода

accounts: prefer nil slices over zero-length slices (#19079)

Matthew Halpern 6 лет назад
Родитель
Сommit
15eee47ebf
2 измененных файлов с 8 добавлено и 4 удалено
  1. 4 2
      accounts/keystore/keystore.go
  2. 4 2
      accounts/usbwallet/hub.go

+ 4 - 2
accounts/keystore/keystore.go

@@ -137,8 +137,10 @@ func (ks *KeyStore) refreshWallets() {
 	accs := ks.cache.accounts()
 
 	// Transform the current list of wallets into the new one
-	wallets := make([]accounts.Wallet, 0, len(accs))
-	events := []accounts.WalletEvent{}
+	var (
+		wallets = make([]accounts.Wallet, 0, len(accs))
+		events  []accounts.WalletEvent
+	)
 
 	for _, account := range accs {
 		// Drop wallets while they were in front of the next account

+ 4 - 2
accounts/usbwallet/hub.go

@@ -150,8 +150,10 @@ func (hub *Hub) refreshWallets() {
 	// Transform the current list of wallets into the new one
 	hub.stateLock.Lock()
 
-	wallets := make([]accounts.Wallet, 0, len(devices))
-	events := []accounts.WalletEvent{}
+	var (
+		wallets = make([]accounts.Wallet, 0, len(devices))
+		events  []accounts.WalletEvent
+	)
 
 	for _, device := range devices {
 		url := accounts.URL{Scheme: hub.scheme, Path: device.Path}