mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 23:07:59 +01:00
[txpackages] use std::lexicographical_compare instead of sorting hex strings
No behavior change, but getting the hex string is more expensive than necessary.
This commit is contained in:
parent
8496f69e1c
commit
9a762efc7a
1 changed files with 4 additions and 1 deletions
|
@ -156,7 +156,10 @@ uint256 GetPackageHash(const std::vector<CTransactionRef>& transactions)
|
|||
[](const auto& tx){ return tx->GetWitnessHash(); });
|
||||
|
||||
// Sort in ascending order
|
||||
std::sort(wtxids_copy.begin(), wtxids_copy.end(), [](const auto& lhs, const auto& rhs) { return lhs.GetHex() < rhs.GetHex(); });
|
||||
std::sort(wtxids_copy.begin(), wtxids_copy.end(), [](const auto& lhs, const auto& rhs) {
|
||||
return std::lexicographical_compare(std::make_reverse_iterator(lhs.end()), std::make_reverse_iterator(lhs.begin()),
|
||||
std::make_reverse_iterator(rhs.end()), std::make_reverse_iterator(rhs.begin()));
|
||||
});
|
||||
|
||||
// Get sha256 hash of the wtxids concatenated in this order
|
||||
HashWriter hashwriter;
|
||||
|
|
Loading…
Add table
Reference in a new issue