aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2013-06-13 01:29:39 +0000
committerlloyd <[email protected]>2013-06-13 01:29:39 +0000
commitfbcff1ecf40ad4014f474e1dc9691c9895137d52 (patch)
treeed302c5a84750f5df52287bba1ec2d4d098dd3bf /src
parent195a1434006e288416886960e9cf9e81d49e0a58 (diff)
Change same_mem to use XORs instead of equality operators.
Potentially less prone to optimizer trickery wrt early exits, especially as it encourages a SIMD approach which modern compilers tend to prefer if they think they can get away with it.
Diffstat (limited to 'src')
-rw-r--r--src/utils/mem_ops.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/utils/mem_ops.h b/src/utils/mem_ops.h
index 92a130310..be617ff19 100644
--- a/src/utils/mem_ops.h
+++ b/src/utils/mem_ops.h
@@ -62,12 +62,12 @@ inline void set_mem(T* ptr, size_t n, byte val)
*/
template<typename T> inline bool same_mem(const T* p1, const T* p2, size_t n)
{
- bool is_same = true;
+ volatile T difference = 0;
for(size_t i = 0; i != n; ++i)
- is_same &= (p1[i] == p2[i]);
+ difference |= (p1[i] ^ p2[i]);
- return is_same;
+ return difference == 0;
}
}