Browse Source

Merge #7712: Improve COutPoint less operator

0f17692 Improve COutPoint less operator (João Barbosa)
0.13
Wladimir J. van der Laan 9 years ago
parent
commit
3c27067dd2
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 3
      src/primitives/transaction.h
  2. 8
      src/uint256.h

3
src/primitives/transaction.h

@ -34,7 +34,8 @@ public: @@ -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)

8
src/uint256.h

@ -42,9 +42,11 @@ public: @@ -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);

Loading…
Cancel
Save