[PATCH 6 of 6 RFC] radixlink: use C radixlink get implementation if available

Augie Fackler raf at durin42.com
Wed May 24 17:26:05 EDT 2017


On Sun, May 21, 2017 at 06:31:13PM -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1495409961 25200
> #      Sun May 21 16:39:21 2017 -0700
> # Node ID b69ca9116b2cae29fd182c7bb545e59f16455d3f
> # Parent  6916f2eede1507237cffdb62db1baff8ded04ea5
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r b69ca9116b2c
> radixlink: use C radixlink get implementation if available

Overall it sounds like this is worth doing, especially since it sounds
like it could also be used for things like speeding up node->rev
conversions later on.

I didn't go over the specifics of the implementation /too/ carefully,
but it looked reasonable. Care to do a v2 with timing information
added to this last commit?

>
> diff --git a/mercurial/radixlink.py b/mercurial/radixlink.py
> --- a/mercurial/radixlink.py
> +++ b/mercurial/radixlink.py
> @@ -12,6 +12,10 @@ import struct
>  from . import (
>      error,
> +    policy,
> +    util,
>  )
>
> +parsers = policy.importmod(r'parsers')
> +
>  def _enlarge(buf, size):
>      """enlarge a bytearray to at least given size"""
> @@ -134,4 +138,11 @@ class radixlink(object):
>          return result
>
> +    if util.safehasattr(parsers, 'radixlinkget'):
> +        # replace radixlink.get with a faster version
> +        def get(self, key):
> +            index = buffer(self.indexdata)
> +            link = buffer(self.linkdata)
> +            return parsers.radixlinkget(index, link, key)
> +
>      def insert(self, key, value):
>          """key: int, value: buffer"""
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list