Just memcpy data that might not be aligned
It'll be plenty fast for us. I suspect it's going to be just as fast
anywhere, but I'll argue about that with upstream later when I try
upstreaming this. The big advantage is it's definitely well-defined now,
vs before the attempt at using nullptr to make it work on hypothetical
C++ implementations that do weird things with pointers did not actually
do that, and triggered Clang warnings because it wasn't doing anything
useful.
Change-Id: I3c239b94b45449dc0a73c2c445778d72db8319df
Signed-off-by: Brian Silverman <bsilver16834@gmail.com>
diff --git a/third_party/seasocks/src/main/c/md5/md5.cpp b/third_party/seasocks/src/main/c/md5/md5.cpp
index 64c1f02..76ef31b 100644
--- a/third_party/seasocks/src/main/c/md5/md5.cpp
+++ b/third_party/seasocks/src/main/c/md5/md5.cpp
@@ -173,28 +173,18 @@
{
#if BYTE_ORDER == 0
/*
- * Determine dynamically whether this is a big-endian or
- * little-endian machine, since we can use a more efficient
- * algorithm on the latter.
- */
+ * Determine dynamically whether this is a big-endian or
+ * little-endian machine, since we can use a more efficient
+ * algorithm on the latter.
+ */
static const int w = 1;
if (*((const md5_byte_t*) &w)) /* dynamic little-endian */
#endif
#if BYTE_ORDER <= 0 /* little-endian */
{
- /*
- * On little-endian machines, we can process properly aligned
- * data without copying it.
- */
- if (!((data - (const md5_byte_t*) 0) & 3)) {
- /* data are properly aligned */
- X = (const md5_word_t*) data;
- } else {
- /* not aligned */
- memcpy(xbuf, data, 64);
- X = xbuf;
- }
+ memcpy(xbuf, data, 64);
+ X = xbuf;
}
#endif
#if BYTE_ORDER == 0
@@ -203,9 +193,9 @@
#if BYTE_ORDER >= 0 /* big-endian */
{
/*
- * On big-endian machines, we must arrange the bytes in the
- * right order.
- */
+ * On big-endian machines, we must arrange the bytes in the
+ * right order.
+ */
const md5_byte_t* xp = data;
int i;