Patchwork [3,of,4] zeroconf: replace reduce+add with itertools.chain

login
register
mail settings
Submitter timeless@mozdev.org
Date March 9, 2016, 4:24 a.m.
Message ID <8e2e04f015097b7df712.1457497440@waste.org>
Download mbox | patch
Permalink /patch/13703/
State Accepted
Headers show

Comments

timeless@mozdev.org - March 9, 2016, 4:24 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1456827527 0
#      Tue Mar 01 10:18:47 2016 +0000
# Node ID 8e2e04f015097b7df7121a8bc840ee8c43cb59d3
# Parent  4c53a5e481d5c7a7a02e0037dfcbfa2c3790eb35
zeroconf: replace reduce+add with itertools.chain

Patch

diff --git a/hgext/zeroconf/Zeroconf.py b/hgext/zeroconf/Zeroconf.py
--- a/hgext/zeroconf/Zeroconf.py
+++ b/hgext/zeroconf/Zeroconf.py
@@ -80,6 +80,7 @@ 
 __email__ = "paul at scott dash murphy dot com"
 __version__ = "0.12"
 
+import itertools
 import select
 import socket
 import string
@@ -852,9 +853,8 @@ 
 
     def entries(self):
         """Returns a list of all entries"""
-        def add(x, y): return x + y
         try:
-            return reduce(add, self.cache.values())
+            return list(itertools.chain.from_iterable(self.cache.values()))
         except Exception:
             return []