largefiles: avoid redundant loop to eliminate None from list
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Mon, 27 Mar 2017 09:44:35 +0900
changeset 31656 0192aa8626c1
parent 31655 9d075911df49
child 31657 641f3a6098d0
largefiles: avoid redundant loop to eliminate None from list Before this patch, this code path contains two loops for m._files: one for replacement with standin, and another for elimination of None, which comes from previous replacement ("standin in wctx or lfdirstate[f] == 'r'" case in tostandin()). These two loops can be unified into simple one "for" loop.
hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py	Mon Mar 27 09:44:35 2017 +0900
+++ b/hgext/largefiles/overrides.py	Mon Mar 27 09:44:35 2017 +0900
@@ -759,15 +759,16 @@
                                                False)
 
             wctx = repo[None]
-            def tostandin(f):
+            matchfiles = []
+            for f in m._files:
                 standin = lfutil.standin(f)
                 if standin in ctx or standin in mctx:
-                    return standin
+                    matchfiles.append(standin)
                 elif standin in wctx or lfdirstate[f] == 'r':
-                    return None
-                return f
-            m._files = [tostandin(f) for f in m._files]
-            m._files = [f for f in m._files if f is not None]
+                    continue
+                else:
+                    matchfiles.append(f)
+            m._files = matchfiles
             m._fileroots = set(m._files)
             origmatchfn = m.matchfn
             def matchfn(f):