mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Add isZero/isNonZero to avoid !!hash constructs.
This commit is contained in:
15
uint256.h
15
uint256.h
@@ -33,6 +33,19 @@ protected:
|
|||||||
unsigned int pn[WIDTH];
|
unsigned int pn[WIDTH];
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
bool isZero() const
|
||||||
|
{
|
||||||
|
for (int i = 0; i < WIDTH; i++)
|
||||||
|
if (pn[i] != 0)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isNonZero() const
|
||||||
|
{
|
||||||
|
return !isZero();
|
||||||
|
}
|
||||||
|
|
||||||
bool operator!() const
|
bool operator!() const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < WIDTH; i++)
|
for (int i = 0; i < WIDTH; i++)
|
||||||
@@ -279,7 +292,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend inline bool operator!=(const base_uint& a, const base_uint& b)
|
friend inline bool operator!=(const base_uint& a, const base_uint& b)
|
||||||
{
|
{
|
||||||
return (!(a == b));
|
return (!(a == b));
|
||||||
|
|||||||
Reference in New Issue
Block a user