diff options
author | glozow <gloriajzhao@gmail.com> | 2024-05-01 13:33:30 +0100 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2024-05-01 13:34:37 +0100 |
commit | 9a762efc7a118c44556fa9ad404f6b54103bad41 (patch) | |
tree | a80305b0f96df60f6d08fece62f3c89ed03bc4c5 /src | |
parent | 8496f69e1c2d1961db2604829cb6a289eb8dd3d6 (diff) |
[txpackages] use std::lexicographical_compare instead of sorting hex strings
No behavior change, but getting the hex string is more expensive than
necessary.
Diffstat (limited to 'src')
-rw-r--r-- | src/policy/packages.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/policy/packages.cpp b/src/policy/packages.cpp index 99d2a6d514..693adcdfd0 100644 --- a/src/policy/packages.cpp +++ b/src/policy/packages.cpp @@ -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; |