pathutil: slightly faster path audit in the common case
authorArseniy Alekseyev <aalekseyev@janestreet.com>
Wed, 04 Jan 2023 18:42:20 +0000
changeset 49963 44deb5a164dc
parent 49962 becd16690cbe
child 49964 445b4d819e9a
pathutil: slightly faster path audit in the common case
mercurial/pathutil.py
--- a/mercurial/pathutil.py	Fri Jan 06 16:01:31 2023 +0000
+++ b/mercurial/pathutil.py	Wed Jan 04 18:42:20 2023 +0000
@@ -90,13 +90,14 @@
                 _(b"path contains illegal component: %s") % path
             )
         # Windows shortname aliases
-        for p in parts:
-            if b"~" in p:
-                first, last = p.split(b"~", 1)
-                if last.isdigit() and first.upper() in [b"HG", b"HG8B6C"]:
-                    raise error.InputError(
-                        _(b"path contains illegal component: %s") % path
-                    )
+        if b"~" in path:
+            for p in parts:
+                if b"~" in p:
+                    first, last = p.split(b"~", 1)
+                    if last.isdigit() and first.upper() in [b"HG", b"HG8B6C"]:
+                        raise error.InputError(
+                            _(b"path contains illegal component: %s") % path
+                        )
         if b'.hg' in _lowerclean(path):
             lparts = [_lowerclean(p) for p in parts]
             for p in b'.hg', b'.hg.':