[PATCH 05 of 11 V1] store: optimize _pathencode by checking the length of the unencoded path

Adrian Buehlmann adrian at cadifra.com
Sun Sep 30 16:56:42 CDT 2012


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1349042036 -7200
# Node ID e6d3bef190ac0cf58ed69becdb143eb86fc65c16
# Parent  6937206a96c8235bebc65592e28782ffe827d99c
store: optimize _pathencode by checking the length of the unencoded path

If the input path is already longer than _maxstorepathlen, then we can skip
doing the basic encoding (encodedir, _encodefname and _auxencode) and directly
proceed to the hashed encoding. Those encodings, if at all, will make the path
only longer.

diff --git a/mercurial/store.py b/mercurial/store.py
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -255,6 +255,8 @@
     return res
 
 def _pathencode(path):
+    if len(path) > _maxstorepathlen:
+        return None
     ef = _encodefname(encodedir(path)).split('/')
     res = '/'.join(_auxencode(ef, True))
     if len(res) > _maxstorepathlen:


More information about the Mercurial-devel mailing list