mirror of
https://github.com/fluffle/goirc
synced 2025-05-13 02:53:19 +00:00
change channel reads to use 'for v := range ch {}' idiom
This commit is contained in:
parent
7f6c8fc232
commit
af8dfdb6f3
2 changed files with 11 additions and 31 deletions
|
@ -115,11 +115,7 @@ func hasPort(s string) bool { return strings.LastIndex(s, ":") > strings.LastInd
|
|||
// dispatch input from channel as \r\n terminated line to peer
|
||||
// flood controlled using hybrid's algorithm if conn.Flood is true
|
||||
func (conn *Conn) send() {
|
||||
for {
|
||||
if closed(conn.out) {
|
||||
break
|
||||
}
|
||||
line := <-conn.out
|
||||
for line := range conn.out {
|
||||
if err := conn.io.WriteString(line + "\r\n"); err != nil {
|
||||
conn.error("irc.send(): %s", err.String())
|
||||
conn.shutdown()
|
||||
|
@ -191,14 +187,8 @@ func (conn *Conn) recv() {
|
|||
}
|
||||
|
||||
func (conn *Conn) runLoop() {
|
||||
for {
|
||||
if closed(conn.in) {
|
||||
break
|
||||
}
|
||||
select {
|
||||
case line := <-conn.in:
|
||||
for line := range conn.in {
|
||||
conn.dispatchEvent(line)
|
||||
}
|
||||
}
|
||||
// if we fall off the end here due to shutdown,
|
||||
// reinit everything once the runloop is done
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue