Merge some minor cleanups by Peter Scott.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 8 Oct 2012 15:58:36 +0000 (11:58 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 8 Oct 2012 15:58:36 +0000 (11:58 -0400)
irkerd

diff --git a/irkerd b/irkerd
index 6ca6363b4df87accfec8821d4f0b885485b82014..e5652423350b0af42e0f5dbaac7dbaf1d9b2a464 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -355,7 +355,7 @@ class Dispatcher:
         return len(self.connections) > 0
     def last_xmit(self):
         "Return the time of the most recent transmission."
-        return max([x.last_xmit for x in self.connections])
+        return max(x.last_xmit for x in self.connections)
 
 class Irker:
     "Persistent IRC multiplexer."
@@ -485,13 +485,8 @@ class Irker:
                             # choose the one longest idle on the
                             # assumption that message activity is likely
                             # to be clumpy.
-                            oldest = None
-                            oldtime = float("inf")
                             if len(self.servers) >= CONNECTION_MAX:
-                                for (name, server) in self.servers.items():
-                                    if server.last_xmit() < oldtime:
-                                        oldest = name
-                                        oldtime = server.last_xmit()
+                                oldest = min(self.servers.keys(), key=lambda name: self.servers[name].last_xmit())
                                 del self.servers[oldest]
         except ValueError:
             self.logerr("can't recognize JSON on input: %r" % line)