comparison mercurial/manifest.py @ 24396:9e03602cd2d8

manifest: avoid intersectfiles for matches > 100 files Previously we tried to avoid manifest.intersectfiles for exact matches with less than 100 files. However, when the left side of the "or" is false, the right side gets evaluated, of course, and the evaluation of "util.all(fn in self for fn in files)" is both costly in itself, and likely to be true, causing intersectfiles() to be called after all. Fix this by moving the check for less than 100 files outside of the "or" expression, thereby also making it apply for a non-exact matcher, should one be passed in.
author Durham Goode <durham@fb.com>
date Wed, 18 Mar 2015 15:59:45 -0700
parents 7002ad149f30
children e6e023d57e94
comparison
equal deleted inserted replaced
24395:216fa1ba9993 24396:9e03602cd2d8
162 '''generate a new manifest filtered by the match argument''' 162 '''generate a new manifest filtered by the match argument'''
163 if match.always(): 163 if match.always():
164 return self.copy() 164 return self.copy()
165 165
166 files = match.files() 166 files = match.files()
167 if ((match.matchfn == match.exact and len(files) < 100) or 167 if (len(files) < 100 and (match.matchfn == match.exact or
168 (not match.anypats() and util.all(fn in self for fn in files))): 168 (not match.anypats() and util.all(fn in self for fn in files)))):
169 return self.intersectfiles(files) 169 return self.intersectfiles(files)
170 170
171 lm = manifestdict('') 171 lm = manifestdict('')
172 lm._lm = self._lm.filtercopy(match) 172 lm._lm = self._lm.filtercopy(match)
173 return lm 173 return lm