[PATCH 7 of 8 faster-obsmarkers] getbeint16: write in terms of getbeuint16

Augie Fackler raf at durin42.com
Mon Feb 2 10:12:09 CST 2015


Similarly, I'm slightly fuzzy on how this cast behaves. If it's legal,
please consider folding it into the patch that introduces getbeint16.

On Mon, Feb 2, 2015 at 11:01 AM, Augie Fackler <raf at durin42.com> wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz at google.com>
> # Date 1421791151 28800
> #      Tue Jan 20 13:59:11 2015 -0800
> # Branch stable
> # Node ID 6969fa0e9ab6ae8c4642ea1f90e9374e4e5a9b28
> # Parent  22d73e82c50d1126c7640d960cf74fcf328add6c
> getbeint16: write in terms of getbeuint16
>
> diff --git a/mercurial/util.h b/mercurial/util.h
> --- a/mercurial/util.h
> +++ b/mercurial/util.h
> @@ -172,7 +172,7 @@ static inline uint32_t getbe32(const cha
>                 (d[3]));
>  }
>
> -static inline int16_t getbeint16(const char *c)
> +static inline uint16_t getbeuint16(const char *c)
>  {
>         const unsigned char *d = (const unsigned char *)c;
>
> @@ -180,12 +180,9 @@ static inline int16_t getbeint16(const c
>                 (d[1]));
>  }
>
> -static inline uint16_t getbeuint16(const char *c)
> +static inline int16_t getbeint16(const char *c)
>  {
> -       const unsigned char *d = (const unsigned char *)c;
> -
> -       return ((d[0] << 8) |
> -               (d[1]));
> +       return (int16_t)getbeuint16(c);
>  }
>
>  static inline void putbe32(uint32_t x, char *c)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list