mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-25 13:29:27 +01:00
use maps.Clone from go1.21
This commit is contained in:
parent
28d9a7ff63
commit
f77d430d25
@ -7,6 +7,7 @@ package irc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -158,7 +159,7 @@ func (channel *Channel) ExportRegistration() (info RegisteredChannel) {
|
|||||||
info.Bans = channel.lists[modes.BanMask].Masks()
|
info.Bans = channel.lists[modes.BanMask].Masks()
|
||||||
info.Invites = channel.lists[modes.InviteMask].Masks()
|
info.Invites = channel.lists[modes.InviteMask].Masks()
|
||||||
info.Excepts = channel.lists[modes.ExceptMask].Masks()
|
info.Excepts = channel.lists[modes.ExceptMask].Masks()
|
||||||
info.AccountToUMode = utils.CopyMap(channel.accountToUMode)
|
info.AccountToUMode = maps.Clone(channel.accountToUMode)
|
||||||
|
|
||||||
info.Settings = channel.settings
|
info.Settings = channel.settings
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ package irc
|
|||||||
import (
|
import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"net"
|
"net"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -1743,7 +1744,7 @@ func (client *Client) handleRegisterTimeout() {
|
|||||||
func (client *Client) copyLastSeen() (result map[string]time.Time) {
|
func (client *Client) copyLastSeen() (result map[string]time.Time) {
|
||||||
client.stateMutex.RLock()
|
client.stateMutex.RLock()
|
||||||
defer client.stateMutex.RUnlock()
|
defer client.stateMutex.RUnlock()
|
||||||
return utils.CopyMap(client.lastSeen)
|
return maps.Clone(client.lastSeen)
|
||||||
}
|
}
|
||||||
|
|
||||||
// these are bit flags indicating what part of the client status is "dirty"
|
// these are bit flags indicating what part of the client status is "dirty"
|
||||||
|
@ -4,9 +4,8 @@
|
|||||||
package irc
|
package irc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"maps"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ergochat/ergo/irc/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// fakelag is a system for artificially delaying commands when a user issues
|
// fakelag is a system for artificially delaying commands when a user issues
|
||||||
@ -40,7 +39,7 @@ func (fl *Fakelag) Initialize(config FakelagConfig) {
|
|||||||
fl.config = config
|
fl.config = config
|
||||||
// XXX don't share mutable member CommandBudgets:
|
// XXX don't share mutable member CommandBudgets:
|
||||||
if config.CommandBudgets != nil {
|
if config.CommandBudgets != nil {
|
||||||
fl.config.CommandBudgets = utils.CopyMap(config.CommandBudgets)
|
fl.config.CommandBudgets = maps.Clone(config.CommandBudgets)
|
||||||
}
|
}
|
||||||
fl.nowFunc = time.Now
|
fl.nowFunc = time.Now
|
||||||
fl.sleepFunc = time.Sleep
|
fl.sleepFunc = time.Sleep
|
||||||
|
@ -5,6 +5,7 @@ package irc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -515,7 +516,7 @@ func (client *Client) GetReadMarker(cfname string) (result string) {
|
|||||||
func (client *Client) copyReadMarkers() (result map[string]time.Time) {
|
func (client *Client) copyReadMarkers() (result map[string]time.Time) {
|
||||||
client.stateMutex.RLock()
|
client.stateMutex.RLock()
|
||||||
defer client.stateMutex.RUnlock()
|
defer client.stateMutex.RUnlock()
|
||||||
return utils.CopyMap(client.readMarkers)
|
return maps.Clone(client.readMarkers)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) SetReadMarker(cfname string, now time.Time) (result time.Time) {
|
func (client *Client) SetReadMarker(cfname string, now time.Time) (result time.Time) {
|
||||||
|
@ -27,11 +27,3 @@ func SetLiteral[T comparable](elems ...T) HashSet[T] {
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func CopyMap[K comparable, V any](input map[K]V) (result map[K]V) {
|
|
||||||
result = make(map[K]V, len(input))
|
|
||||||
for key, value := range input {
|
|
||||||
result[key] = value
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user