diff --git a/irc/channel.go b/irc/channel.go index 4680958c..4dc5bccb 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -7,6 +7,7 @@ package irc import ( "fmt" + "maps" "strconv" "strings" "time" @@ -158,7 +159,7 @@ func (channel *Channel) ExportRegistration() (info RegisteredChannel) { info.Bans = channel.lists[modes.BanMask].Masks() info.Invites = channel.lists[modes.InviteMask].Masks() info.Excepts = channel.lists[modes.ExceptMask].Masks() - info.AccountToUMode = utils.CopyMap(channel.accountToUMode) + info.AccountToUMode = maps.Clone(channel.accountToUMode) info.Settings = channel.settings diff --git a/irc/client.go b/irc/client.go index 237b5aad..80a60a23 100644 --- a/irc/client.go +++ b/irc/client.go @@ -8,6 +8,7 @@ package irc import ( "crypto/x509" "fmt" + "maps" "net" "runtime/debug" "strconv" @@ -1743,7 +1744,7 @@ func (client *Client) handleRegisterTimeout() { func (client *Client) copyLastSeen() (result map[string]time.Time) { client.stateMutex.RLock() 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" diff --git a/irc/fakelag.go b/irc/fakelag.go index 25ef0609..4a533981 100644 --- a/irc/fakelag.go +++ b/irc/fakelag.go @@ -4,9 +4,8 @@ package irc import ( + "maps" "time" - - "github.com/ergochat/ergo/irc/utils" ) // 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 // XXX don't share mutable member CommandBudgets: if config.CommandBudgets != nil { - fl.config.CommandBudgets = utils.CopyMap(config.CommandBudgets) + fl.config.CommandBudgets = maps.Clone(config.CommandBudgets) } fl.nowFunc = time.Now fl.sleepFunc = time.Sleep diff --git a/irc/getters.go b/irc/getters.go index 19b162f4..baf86cc6 100644 --- a/irc/getters.go +++ b/irc/getters.go @@ -5,6 +5,7 @@ package irc import ( "fmt" + "maps" "net" "time" @@ -515,7 +516,7 @@ func (client *Client) GetReadMarker(cfname string) (result string) { func (client *Client) copyReadMarkers() (result map[string]time.Time) { client.stateMutex.RLock() 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) { diff --git a/irc/utils/types.go b/irc/utils/types.go index 6b297c51..8d136f34 100644 --- a/irc/utils/types.go +++ b/irc/utils/types.go @@ -27,11 +27,3 @@ func SetLiteral[T comparable](elems ...T) HashSet[T] { } 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 -}