[PATCH 6 of 8 faster-obsmarkers] getbefloat64: drop unnecessary memcpy
Augie Fackler
raf at durin42.com
Mon Feb 2 10:11:37 CST 2015
I originally had written this, but then someone mumbled something
about strict aliasing rules in C. Since I have no idea if this is
actually legal, I left it as its own patch.
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 1421790379 28800
> # Tue Jan 20 13:46:19 2015 -0800
> # Branch stable
> # Node ID 22d73e82c50d1126c7640d960cf74fcf328add6c
> # Parent bbd5e20889d06d6dccc8b3e83946d65d0cc79570
> getbefloat64: drop unnecessary memcpy
>
> diff --git a/mercurial/util.h b/mercurial/util.h
> --- a/mercurial/util.h
> +++ b/mercurial/util.h
> @@ -199,14 +199,12 @@ static inline void putbe32(uint32_t x, c
> static inline double getbefloat64(const char *c)
> {
> const unsigned char *d = (const unsigned char *)c;
> - double ret;
> int i;
> uint64_t t = 0;
> for (i = 0; i < 8; i++) {
> t = (t<<8) + d[i];
> }
> - memcpy(&ret, &t, sizeof(t));
> - return ret;
> + return *((const double*)&t);
> }
>
> #endif /* _HG_UTIL_H_ */
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list