changeset 34069:ca6a3852daf0

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
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 31 Aug 2017 19:40:15 -0700
parents d2fc88426d21
children 24ce7b0edaf9
files mercurial/util.py
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Fri Sep 01 11:52:20 2017 -0700
+++ b/mercurial/util.py	Thu Aug 31 19:40:15 2017 -0700
@@ -1230,9 +1230,11 @@
 
     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.