[PATCH 2 of 8 faster-obsmarkers] util: add getbe{u, }int16 utility methods

Martin von Zweigbergk martinvonz at google.com
Mon Feb 2 12:26:40 CST 2015


On Mon Feb 02 2015 at 8:03:12 AM Augie Fackler <raf at durin42.com> wrote:

> # HG changeset patch
> # User Augie Fackler <augie at google.com>
> # Date 1421780997 18000
> #      Tue Jan 20 14:09:57 2015 -0500
> # Branch stable
> # Node ID 20ac130001c176b0fbc2c99d9fe3741df3b71bca
> # Parent  a981174fee88c527794466a487ff07a46c329512
> util: add getbe{u,}int16 utility methods
>
> diff --git a/mercurial/util.h b/mercurial/util.h
> --- a/mercurial/util.h
> +++ b/mercurial/util.h
> @@ -172,6 +172,22 @@ static inline uint32_t getbe32(const cha
>                 (d[3]));
>  }
>
> +static inline int16_t getbeint16(const char *c)
> +{
> +       const unsigned char *d = (const unsigned char *)c;
> +
> +       return ((d[0] << 8) |
> +               (d[1]));
>

Nit: For numbers with more bits, I can see why this formatting makes sense,
but here I find it more distracting that a single line would have been.


> +}
> +
> +static inline uint16_t getbeuint16(const char *c)
> +{
> +       const unsigned char *d = (const unsigned char *)c;
> +
> +       return ((d[0] << 8) |
> +               (d[1]));
> +}
> +
>  static inline void putbe32(uint32_t x, char *c)
>  {
>         c[0] = (x >> 24) & 0xff;
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150202/b594569d/attachment.html>


More information about the Mercurial-devel mailing list