Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2025-03-23 12:52:24 +08:00
commit 072f98c9ae
3 changed files with 35 additions and 10 deletions

View file

@ -14,6 +14,7 @@
#include "mozilla/MathAlgorithms.h"
#include "mozilla/Types.h"
#include <algorithm>
#include <stdint.h>
namespace mozilla {
@ -450,6 +451,30 @@ EqualOrBothNaN(T aValue1, T aValue2)
return aValue1 == aValue2;
}
/**
* Return NaN if either |aValue1| or |aValue2| is NaN, or the minimum of
* |aValue1| and |aValue2| otherwise.
*/
template <typename T>
static inline T NaNSafeMin(T aValue1, T aValue2) {
if (IsNaN(aValue1) || IsNaN(aValue2)) {
return UnspecifiedNaN<T>();
}
return std::min(aValue1, aValue2);
}
/**
* Return NaN if either |aValue1| or |aValue2| is NaN, or the maximum of
* |aValue1| and |aValue2| otherwise.
*/
template <typename T>
static inline T NaNSafeMax(T aValue1, T aValue2) {
if (IsNaN(aValue1) || IsNaN(aValue2)) {
return UnspecifiedNaN<T>();
}
return std::max(aValue1, aValue2);
}
namespace detail {
template<typename T>