Skip to content

Commit

Permalink
Revert "use lexicographical_compare_three_way"
Browse files Browse the repository at this point in the history
This reverts commit 54038d2.
  • Loading branch information
instagibbs committed Jan 19, 2024
1 parent 1dba42f commit 5f726be
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/test/fuzz/feefrac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>

#include <algorithm>
#include <compare>
#include <cstdint>
#include <iostream>
Expand Down Expand Up @@ -45,6 +44,15 @@ std::array<uint32_t, 4> Mul128(uint64_t a, uint64_t b)
return ret;
}

/* comparison helper for std::vector */
std::strong_ordering compare_arrays(const std::array<uint32_t, 4>& a, const std::array<uint32_t, 4>& b) {
for (size_t i = 0; i < a.size(); ++i) {
if (a[i] < b[i]) return std::strong_ordering::less;
if (a[i] > b[i]) return std::strong_ordering::greater;
}
return std::strong_ordering::equal;
}

std::strong_ordering MulCompare(int64_t a1, int64_t a2, int64_t b1, int64_t b2)
{
// Compute and compare signs.
Expand All @@ -64,9 +72,9 @@ std::strong_ordering MulCompare(int64_t a1, int64_t a2, int64_t b1, int64_t b2)
auto mul_abs_a = Mul128(abs_a1, abs_a2);
auto mul_abs_b = Mul128(abs_b1, abs_b2);
if (sign_a < 0) {
return std::lexicographical_compare_three_way(mul_abs_b.begin(), mul_abs_b.end(), mul_abs_a.begin(), mul_abs_a.end());
return compare_arrays(mul_abs_b, mul_abs_a);
} else {
return std::lexicographical_compare_three_way(mul_abs_a.begin(), mul_abs_a.end(), mul_abs_b.begin(), mul_abs_b.end());
return compare_arrays(mul_abs_a, mul_abs_b);
}
}

Expand Down

0 comments on commit 5f726be

Please sign in to comment.