[PATCH] pathencode: skip encoding if input is already longer than maxstorepathlen

Adrian Buehlmann adrian at cadifra.com
Fri Sep 21 17:50:55 CDT 2012


On 2012-09-21 23:04, Adrian Buehlmann wrote:
> # HG changeset patch
> # User Adrian Buehlmann <adrian at cadifra.com>
> # Date 1348261363 -7200
> # Node ID b532af187425e6ff650b5c112bf553b52ae4c560
> # Parent  331d611813eca2098fdb75c741cb7f5cc72b6567
> pathencode: skip encoding if input is already longer than maxstorepathlen
> 
> Calling basicencode may make the path longer, never shorter. If it's already
> too long before, then we don't even need to basicencode it.
> 
> diff --git a/mercurial/pathencode.c b/mercurial/pathencode.c
> --- a/mercurial/pathencode.c
> +++ b/mercurial/pathencode.c
> @@ -508,6 +508,12 @@
>  		return NULL;
>  	}
>  
> +	if (len > maxstorepathlen) {

For my Netbeans clone here, this "if" is true for 32798 of 120151
entries of the fncache file (27% of the entries).

> +		newobj = Py_None;
> +		Py_INCREF(newobj);
> +		return newobj;
> +	}
> +
>  	newlen = len ? basicencode(NULL, 0, path, len + 1) : 1;
>  
>  	if (newlen <= maxstorepathlen + 1) {


More information about the Mercurial-devel mailing list