Bladeren bron

use maps.Clone from go1.21

tags/v2.12.0-rc1
Shivaram Lingamneni 9 maanden geleden
bovenliggende
commit
f77d430d25
5 gewijzigde bestanden met toevoegingen van 8 en 14 verwijderingen
  1. 2
    1
      irc/channel.go
  2. 2
    1
      irc/client.go
  3. 2
    3
      irc/fakelag.go
  4. 2
    1
      irc/getters.go
  5. 0
    8
      irc/utils/types.go

+ 2
- 1
irc/channel.go Bestand weergeven

7
 
7
 
8
 import (
8
 import (
9
 	"fmt"
9
 	"fmt"
10
+	"maps"
10
 	"strconv"
11
 	"strconv"
11
 	"strings"
12
 	"strings"
12
 	"time"
13
 	"time"
158
 	info.Bans = channel.lists[modes.BanMask].Masks()
159
 	info.Bans = channel.lists[modes.BanMask].Masks()
159
 	info.Invites = channel.lists[modes.InviteMask].Masks()
160
 	info.Invites = channel.lists[modes.InviteMask].Masks()
160
 	info.Excepts = channel.lists[modes.ExceptMask].Masks()
161
 	info.Excepts = channel.lists[modes.ExceptMask].Masks()
161
-	info.AccountToUMode = utils.CopyMap(channel.accountToUMode)
162
+	info.AccountToUMode = maps.Clone(channel.accountToUMode)
162
 
163
 
163
 	info.Settings = channel.settings
164
 	info.Settings = channel.settings
164
 
165
 

+ 2
- 1
irc/client.go Bestand weergeven

8
 import (
8
 import (
9
 	"crypto/x509"
9
 	"crypto/x509"
10
 	"fmt"
10
 	"fmt"
11
+	"maps"
11
 	"net"
12
 	"net"
12
 	"runtime/debug"
13
 	"runtime/debug"
13
 	"strconv"
14
 	"strconv"
1743
 func (client *Client) copyLastSeen() (result map[string]time.Time) {
1744
 func (client *Client) copyLastSeen() (result map[string]time.Time) {
1744
 	client.stateMutex.RLock()
1745
 	client.stateMutex.RLock()
1745
 	defer client.stateMutex.RUnlock()
1746
 	defer client.stateMutex.RUnlock()
1746
-	return utils.CopyMap(client.lastSeen)
1747
+	return maps.Clone(client.lastSeen)
1747
 }
1748
 }
1748
 
1749
 
1749
 // these are bit flags indicating what part of the client status is "dirty"
1750
 // these are bit flags indicating what part of the client status is "dirty"

+ 2
- 3
irc/fakelag.go Bestand weergeven

4
 package irc
4
 package irc
5
 
5
 
6
 import (
6
 import (
7
+	"maps"
7
 	"time"
8
 	"time"
8
-
9
-	"github.com/ergochat/ergo/irc/utils"
10
 )
9
 )
11
 
10
 
12
 // fakelag is a system for artificially delaying commands when a user issues
11
 // fakelag is a system for artificially delaying commands when a user issues
40
 	fl.config = config
39
 	fl.config = config
41
 	// XXX don't share mutable member CommandBudgets:
40
 	// XXX don't share mutable member CommandBudgets:
42
 	if config.CommandBudgets != nil {
41
 	if config.CommandBudgets != nil {
43
-		fl.config.CommandBudgets = utils.CopyMap(config.CommandBudgets)
42
+		fl.config.CommandBudgets = maps.Clone(config.CommandBudgets)
44
 	}
43
 	}
45
 	fl.nowFunc = time.Now
44
 	fl.nowFunc = time.Now
46
 	fl.sleepFunc = time.Sleep
45
 	fl.sleepFunc = time.Sleep

+ 2
- 1
irc/getters.go Bestand weergeven

5
 
5
 
6
 import (
6
 import (
7
 	"fmt"
7
 	"fmt"
8
+	"maps"
8
 	"net"
9
 	"net"
9
 	"time"
10
 	"time"
10
 
11
 
515
 func (client *Client) copyReadMarkers() (result map[string]time.Time) {
516
 func (client *Client) copyReadMarkers() (result map[string]time.Time) {
516
 	client.stateMutex.RLock()
517
 	client.stateMutex.RLock()
517
 	defer client.stateMutex.RUnlock()
518
 	defer client.stateMutex.RUnlock()
518
-	return utils.CopyMap(client.readMarkers)
519
+	return maps.Clone(client.readMarkers)
519
 }
520
 }
520
 
521
 
521
 func (client *Client) SetReadMarker(cfname string, now time.Time) (result time.Time) {
522
 func (client *Client) SetReadMarker(cfname string, now time.Time) (result time.Time) {

+ 0
- 8
irc/utils/types.go Bestand weergeven

27
 	}
27
 	}
28
 	return result
28
 	return result
29
 }
29
 }
30
-
31
-func CopyMap[K comparable, V any](input map[K]V) (result map[K]V) {
32
-	result = make(map[K]V, len(input))
33
-	for key, value := range input {
34
-		result[key] = value
35
-	}
36
-	return
37
-}

Laden…
Annuleren
Opslaan