mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
Merge bitcoin/bitcoin#33332: common: Make arith_uint256 trivially copyable
653a9849d5common: Make arith_uint256 trivially copyable (Fabian Jahr) Pull request description: Makes `arith_uint256`/`base_uint` trivially copyable by removing the custom copy constructor and copy assignment operators. Removing of the custom code 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. This was suggested by maflcko here: https://github.com/bitcoin/bitcoin/pull/30469#pullrequestreview-3186533494 ACKs for top commit: Raimo33: ACK653a9849d5l0rinc: ACK653a9849d5achow101: ACK653a9849d5hodlinator: re-ACK653a9849d5Tree-SHA512: 38db5220a2cf773c0c5fb5591671e329b6b87458d972db4f5f3f98c025ec329a8c39b32b5bc24ef8b50b1002b43bb248d8b35aa1c9a56c68c6bbd1d470485bd7
This commit is contained in:
@@ -37,20 +37,8 @@ public:
|
||||
pn[i] = 0;
|
||||
}
|
||||
|
||||
base_uint(const base_uint& b)
|
||||
{
|
||||
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(const base_uint& b) = default;
|
||||
base_uint& operator=(const base_uint& b) = default;
|
||||
|
||||
base_uint(uint64_t b)
|
||||
{
|
||||
@@ -272,6 +260,9 @@ public:
|
||||
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 &);
|
||||
arith_uint256 UintToArith256(const uint256 &);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user