# HG changeset patch # User Gregory Szorc # Date 2017-09-01 02:40:15 # Node ID ca6a3852daf08275d28dcec7696bd32ec9a8bd75 # Parent d2fc88426d21c82450535f952ae413f2bd6aad49 util: use set for reserved Windows filenames 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. Differential Revision: https://phab.mercurial-scm.org/D600 diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1230,9 +1230,11 @@ def copyfiles(src, dst, hardlink=None, p return hardlink, num -_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() +_winreservednames = { + 'con', 'prn', 'aux', 'nul', + 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9', + 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9', +} _winreservedchars = ':*?"<>|' def checkwinfilename(path): r'''Check that the base-relative path is a valid filename on Windows.