[PATCH] V2 of experiment for a simpler path encoding for hashed paths (for "fncache2")

Bryan O'Sullivan bos at serpentine.com
Tue Sep 25 18:29:01 CDT 2012


On Tue, Sep 25, 2012 at 5:53 AM, Adrian Buehlmann <adrian at cadifra.com>wrote:

> V2 of experiment for a simpler path encoding for hashed paths (for
> "fncache2")
>

Interesting approach.


> +                       else if (i + 2 < len) {
> +                               c = encodechar(src[i]);
> +                               c1 = encodechar(src[i + 1]);
> +                               c2 = encodechar(src[i + 2]);
> +                               if ((c == 'a' && c1 == 'u' && c2 == 'x') ||
> +                                   (c == 'c' && c1 == 'o' && c2 == 'n') ||
> +                                   (c == 'p' && c1 == 'r' && c2 == 'n') ||
> +                                   (c == 'n' && c1 == 'u' && c2 == 'l') ||
> +                                   (c == 'c' && c1 == 'o' && c2 == 'm') ||
> +                                   (c == 'l' && c1 == 'p' && c2 == 't')) {
>

This is going to do a lot of branching at the start of every path
component. That's something that can be avoided quite easily using a state
machine.

Otherwise, it looks decent (and now you know how tricky it is to write a
supposedly simple C encoding function!). Have you looked into writing a
pure Python version to see how complex it would be?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20120925/ed52f944/attachment.html>


More information about the Mercurial-devel mailing list