diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-03-21 12:50:09 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-03-21 12:50:47 +0100 |
commit | 3c27067dd2db4c17e7c7c48b4e6db515492559ce (patch) | |
tree | e92deb09b247e0fd5891e61ff427fc71503894f4 | |
parent | 3b4324b1edd7b52bbc0e1f350ab04bc41f343f2e (diff) | |
parent | 0f176927f88084f2f1ce329656878d122fb64623 (diff) | |
download | bitcoin-3c27067dd2db4c17e7c7c48b4e6db515492559ce.tar.xz |
Merge #7712: Improve COutPoint less operator
0f17692 Improve COutPoint less operator (João Barbosa)
-rw-r--r-- | src/primitives/transaction.h | 3 | ||||
-rw-r--r-- | src/uint256.h | 8 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 07ae39e0b4..e124dca365 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -34,7 +34,8 @@ public: friend bool operator<(const COutPoint& a, const COutPoint& b) { - return (a.hash < b.hash || (a.hash == b.hash && a.n < b.n)); + int cmp = a.hash.Compare(b.hash); + return cmp < 0 || (cmp == 0 && a.n < b.n); } friend bool operator==(const COutPoint& a, const COutPoint& b) diff --git a/src/uint256.h b/src/uint256.h index 4495000f2f..bcdb6dd7c2 100644 --- a/src/uint256.h +++ b/src/uint256.h @@ -42,9 +42,11 @@ public: memset(data, 0, sizeof(data)); } - friend inline bool operator==(const base_blob& a, const base_blob& b) { return memcmp(a.data, b.data, sizeof(a.data)) == 0; } - friend inline bool operator!=(const base_blob& a, const base_blob& b) { return memcmp(a.data, b.data, sizeof(a.data)) != 0; } - friend inline bool operator<(const base_blob& a, const base_blob& b) { return memcmp(a.data, b.data, sizeof(a.data)) < 0; } + inline int Compare(const base_blob& other) const { return memcmp(data, other.data, sizeof(data)); } + + friend inline bool operator==(const base_blob& a, const base_blob& b) { return a.Compare(b) == 0; } + friend inline bool operator!=(const base_blob& a, const base_blob& b) { return a.Compare(b) != 0; } + friend inline bool operator<(const base_blob& a, const base_blob& b) { return a.Compare(b) < 0; } std::string GetHex() const; void SetHex(const char* psz); |