Previously, we were performing membership testing against a
list. Change it to a set for a minor perf win. While we're at it,
explode the assignment in place so less work is needed at module
import time.
Details
Details
- Reviewers
quark - Group Reviewers
hg-reviewers - Commits
- rHGca6a3852daf0: util: use set for reserved Windows filenames
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
Comment Actions
LGTM. Maybe include some timing data in commit message:
In [3]: _winreservednames = b'''con prn aux nul ...: com1 com2 com3 com4 com5 com6 com7 com8 com9 ...: lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9'''.split() ...: In [4]: %timeit 'lpt9' in _winreservednames The slowest run took 6.61 times longer than the fastest. This could mean that an intermediate result is being cached. 1000000 loops, best of 3: 288 ns per loop In [5]: %timeit 'con' in _winreservednames The slowest run took 42.41 times longer than the fastest. This could mean that an intermediate result is being cached. 10000000 loops, best of 3: 45 ns per loop In [6]: _winreservednames=set(_winreservednames) In [7]: %timeit 'con' in _winreservednames The slowest run took 28.03 times longer than the fastest. This could mean that an intermediate result is being cached. 10000000 loops, best of 3: 42.5 ns per loop In [8]: %timeit 'lpt9' in _winreservednames 10000000 loops, best of 3: 39.3 ns per loop
Comment Actions
The most relevant test is probably "'not-reserved' in _winreservednames" (which is probably close to the 'lpt9' test).