]> Git Repo - VerusCoin.git/commitdiff
Use memcmp for uint256 equality/inequality
authorPieter Wuille <[email protected]>
Thu, 4 Sep 2014 00:03:39 +0000 (02:03 +0200)
committerPieter Wuille <[email protected]>
Thu, 4 Sep 2014 00:27:04 +0000 (02:27 +0200)
src/uint256.h

index d1a822af0df852dbef2f042a7912329a5e49a248..6bb9a5940047e3fde06d7354ff8efd29db2932a1 100644 (file)
@@ -10,6 +10,7 @@
 #include <stdexcept>
 #include <stdint.h>
 #include <string>
+#include <cstring>
 #include <vector>
 
 class uint_error : public std::runtime_error {
@@ -215,8 +216,8 @@ public:
     friend inline const base_uint operator>>(const base_uint& a, int shift) { return base_uint(a) >>= shift; }
     friend inline const base_uint operator<<(const base_uint& a, int shift) { return base_uint(a) <<= shift; }
     friend inline const base_uint operator*(const base_uint& a, uint32_t b) { return base_uint(a) *= b; }
-    friend inline bool operator==(const base_uint& a, const base_uint& b) { return a.CompareTo(b) == 0; }
-    friend inline bool operator!=(const base_uint& a, const base_uint& b) { return a.CompareTo(b) != 0; }
+    friend inline bool operator==(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) == 0; }
+    friend inline bool operator!=(const base_uint& a, const base_uint& b) { return memcmp(a.pn, b.pn, sizeof(a.pn)) != 0; }
     friend inline bool operator>(const base_uint& a, const base_uint& b) { return a.CompareTo(b) > 0; }
     friend inline bool operator<(const base_uint& a, const base_uint& b) { return a.CompareTo(b) < 0; }
     friend inline bool operator>=(const base_uint& a, const base_uint& b) { return a.CompareTo(b) >= 0; }
This page took 0.028051 seconds and 4 git commands to generate.