common: Make arith_uint256 trivially copyable
Replacing the custom code with default behavior should not result in a change of behavior since base_uint contains a simple array of uint32_t and compiler generated versions of the code could be better optimized.
Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
This commit is contained in:
1 file changed
+5
-14
+5
-14
@@ -37,20 +37,8 @@ public:
|
|||||||
pn[i] = 0;
|
pn[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
base_uint(const base_uint& b)
|
base_uint(const base_uint& b) = default;
|
||||||
{
|
base_uint& operator=(const base_uint& b) = default;
|
||||||
for (int i = 0; i < WIDTH; i++)
|
|
||||||
pn[i] = b.pn[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
base_uint& operator=(const base_uint& b)
|
|
||||||
{
|
|
||||||
if (this != &b) {
|
|
||||||
for (int i = 0; i < WIDTH; i++)
|
|
||||||
pn[i] = b.pn[i];
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
base_uint(uint64_t b)
|
base_uint(uint64_t b)
|
||||||
{
|
{
|
||||||
@@ -272,6 +260,9 @@ public:
|
|||||||
friend arith_uint256 UintToArith256(const uint256 &);
|
friend arith_uint256 UintToArith256(const uint256 &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Keeping the trivially copyable property is beneficial for performance
|
||||||
|
static_assert(std::is_trivially_copyable_v<arith_uint256>);
|
||||||
|
|
||||||
uint256 ArithToUint256(const arith_uint256 &);
|
uint256 ArithToUint256(const arith_uint256 &);
|
||||||
arith_uint256 UintToArith256(const uint256 &);
|
arith_uint256 UintToArith256(const uint256 &);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user