Mercurial > hg
comparison mercurial/fileset.py @ 27463:a8afdc5a7885
fileset: use set instead of list to mark predicates for efficiency (API)
This reduces cost of examining whether given predicate calls
'matchctx.status()' or 'matchctx.existing()' in 'getfileset()' at
runtime.
This kind of examination is used also in subsequent patch, which
detects unintentional 'matchctx.existing()' invocation per each
predicate evaluation.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Mon, 21 Dec 2015 22:31:16 +0900 |
parents | 470ea34ba593 |
children | c39ecb2b86b3 |
comparison
equal
deleted
inserted
replaced
27462:470ea34ba593 | 27463:a8afdc5a7885 |
---|---|
136 # mctx - current matchctx instance | 136 # mctx - current matchctx instance |
137 # x - argument in tree form | 137 # x - argument in tree form |
138 symbols = {} | 138 symbols = {} |
139 | 139 |
140 # filesets using matchctx.status() | 140 # filesets using matchctx.status() |
141 _statuscallers = [] | 141 _statuscallers = set() |
142 | 142 |
143 # filesets using matchctx.existing() | 143 # filesets using matchctx.existing() |
144 _existingcallers = [] | 144 _existingcallers = set() |
145 | 145 |
146 def predicate(decl, callstatus=False, callexisting=False): | 146 def predicate(decl, callstatus=False, callexisting=False): |
147 """Return a decorator for fileset predicate function | 147 """Return a decorator for fileset predicate function |
148 | 148 |
149 'decl' argument is the declaration (including argument list like | 149 'decl' argument is the declaration (including argument list like |
162 name = decl[:i] | 162 name = decl[:i] |
163 else: | 163 else: |
164 name = decl | 164 name = decl |
165 symbols[name] = func | 165 symbols[name] = func |
166 if callstatus: | 166 if callstatus: |
167 _statuscallers.append(name) | 167 _statuscallers.add(name) |
168 if callexisting: | 168 if callexisting: |
169 _existingcallers.append(name) | 169 _existingcallers.add(name) |
170 if func.__doc__: | 170 if func.__doc__: |
171 func.__doc__ = "``%s``\n %s" % (decl, func.__doc__.strip()) | 171 func.__doc__ = "``%s``\n %s" % (decl, func.__doc__.strip()) |
172 return func | 172 return func |
173 return decorator | 173 return decorator |
174 | 174 |