[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:
1 parent
8496f69e1c
commit
9a762efc7a
1 file changed
+4
-1
@@ -156,7 +156,10 @@ uint256 GetPackageHash(const std::vector<CTransactionRef>& transactions)
|
|||||||
[](const auto& tx){ return tx->GetWitnessHash(); });
|
[](const auto& tx){ return tx->GetWitnessHash(); });
|
||||||
|
|
||||||
// Sort in ascending order
|
// 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
|
// Get sha256 hash of the wtxids concatenated in this order
|
||||||
HashWriter hashwriter;
|
HashWriter hashwriter;
|
||||||
|
|||||||
Reference in new issue
Block a user