Changeset 768 in code for trunk


Ignore:
Timestamp:
Feb 4, 2022, 1:01:27 PM (3 years ago)
Author:
contact
Message:

Drop user.forEachNetwork

It's a trivial for loop.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r761 r768  
    352352                f(dc.network)
    353353        } else if dc.isMultiUpstream {
    354                 dc.user.forEachNetwork(f)
     354                for _, network := range dc.user.networks {
     355                        f(network)
     356                }
    355357        }
    356358}
     
    776778
    777779                        var match *network
    778                         dc.user.forEachNetwork(func(net *network) {
     780                        for _, net := range dc.user.networks {
    779781                                if net.ID == id {
    780782                                        match = net
     783                                        break
    781784                                }
    782                         })
     785                        }
    783786                        if match == nil {
    784787                                return ircError{&irc.Message{
     
    14371440        if dc.caps["soju.im/bouncer-networks-notify"] {
    14381441                dc.SendBatch("soju.im/bouncer-networks", nil, nil, func(batchRef irc.TagValue) {
    1439                         dc.user.forEachNetwork(func(network *network) {
     1442                        for _, network := range dc.user.networks {
    14401443                                idStr := fmt.Sprintf("%v", network.ID)
    14411444                                attrs := getNetworkAttrs(network)
     
    14461449                                        Params:  []string{"NETWORK", idStr, attrs.String()},
    14471450                                })
    1448                         })
     1451                        }
    14491452                })
    14501453        }
     
    27492752                case "LISTNETWORKS":
    27502753                        dc.SendBatch("soju.im/bouncer-networks", nil, nil, func(batchRef irc.TagValue) {
    2751                                 dc.user.forEachNetwork(func(network *network) {
     2754                                for _, network := range dc.user.networks {
    27522755                                        idStr := fmt.Sprintf("%v", network.ID)
    27532756                                        attrs := getNetworkAttrs(network)
     
    27582761                                                Params:  []string{"NETWORK", idStr, attrs.String()},
    27592762                                        })
    2760                                 })
     2763                                }
    27612764                        })
    27622765                case "ADDNETWORK":
  • trunk/service.go

    r757 r768  
    507507func handleServiceNetworkStatus(ctx context.Context, dc *downstreamConn, params []string) error {
    508508        n := 0
    509         dc.user.forEachNetwork(func(net *network) {
     509        for _, net := range dc.user.networks {
    510510                var statuses []string
    511511                var details string
     
    542542
    543543                n++
    544         })
     544        }
    545545
    546546        if n == 0 {
     
    970970
    971971        if *networkName == "" {
    972                 dc.user.forEachNetwork(sendNetwork)
     972                for _, net := range dc.user.networks {
     973                        sendNetwork(net)
     974                }
    973975        } else {
    974976                net := dc.user.getNetwork(*networkName)
  • trunk/user.go

    r752 r768  
    465465}
    466466
    467 func (u *user) forEachNetwork(f func(*network)) {
    468         for _, network := range u.networks {
    469                 f(network)
    470         }
    471 }
    472 
    473467func (u *user) forEachUpstream(f func(uc *upstreamConn)) {
    474468        for _, network := range u.networks {
     
    993987                // Re-connect to networks which use the default realname
    994988                var needUpdate []Network
    995                 u.forEachNetwork(func(net *network) {
     989                for _, net := range u.networks {
    996990                        if net.Realname == "" {
    997991                                needUpdate = append(needUpdate, net.Network)
    998992                        }
    999                 })
     993                }
    1000994
    1001995                var netErr error
Note: See TracChangeset for help on using the changeset viewer.