Commit c90ff8bd authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

Implement Min and Max using std::min and std::max

The existing implementation gives different results for certain floating
points values from std::min and std::max. This patch makes it the same,
so it is less surprising.

Took a quick look at some usages for Min and Max, they are all integral
types, so this wouldn't change any behavior.

Min and Max has been in the code base right from the initial import,
and I'm not sure why we needed it, since it should simply be
std::min/std::max. With C++14, std::min and std::max are constexpr,
so this change is also fine.

Change-Id: If8ec53bedff3ef336aa21b082f1a16ce716b8f87
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2464146Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70494}
parent 99e252ba
......@@ -69,13 +69,13 @@ static T ArithmeticShiftRight(T x, int shift) {
// Returns the maximum of the two parameters.
template <typename T>
constexpr T Max(T a, T b) {
return a < b ? b : a;
return std::max(a, b);
}
// Returns the minimum of the two parameters.
template <typename T>
constexpr T Min(T a, T b) {
return a < b ? a : b;
return std::min(a, b);
}
// Returns the maximum of the two parameters according to JavaScript semantics.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment