comparison hgext/largefiles/overrides.py @ 31656:0192aa8626c1

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.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Mon, 27 Mar 2017 09:44:35 +0900
parents 9d075911df49
children 0eec36112e58
comparison
equal deleted inserted replaced
31655:9d075911df49 31656:0192aa8626c1
757 # this invocation of match. 757 # this invocation of match.
758 lfdirstate = lfutil.openlfdirstate(mctx.repo().ui, mctx.repo(), 758 lfdirstate = lfutil.openlfdirstate(mctx.repo().ui, mctx.repo(),
759 False) 759 False)
760 760
761 wctx = repo[None] 761 wctx = repo[None]
762 def tostandin(f): 762 matchfiles = []
763 for f in m._files:
763 standin = lfutil.standin(f) 764 standin = lfutil.standin(f)
764 if standin in ctx or standin in mctx: 765 if standin in ctx or standin in mctx:
765 return standin 766 matchfiles.append(standin)
766 elif standin in wctx or lfdirstate[f] == 'r': 767 elif standin in wctx or lfdirstate[f] == 'r':
767 return None 768 continue
768 return f 769 else:
769 m._files = [tostandin(f) for f in m._files] 770 matchfiles.append(f)
770 m._files = [f for f in m._files if f is not None] 771 m._files = matchfiles
771 m._fileroots = set(m._files) 772 m._fileroots = set(m._files)
772 origmatchfn = m.matchfn 773 origmatchfn = m.matchfn
773 def matchfn(f): 774 def matchfn(f):
774 lfile = lfutil.splitstandin(f) 775 lfile = lfutil.splitstandin(f)
775 if lfile is not None: 776 if lfile is not None: