From c2d0ffbaf3f6b3adc2070fba004aaf4bba218342 Mon Sep 17 00:00:00 2001
From: Andi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Date: Wed, 22 Mar 2023 09:27:58 +0000
Subject: [PATCH] Bug 1660405 - remove unused mozilla::IsNaN. r=sergesanspaille

Differential Revision: https://phabricator.services.mozilla.com/D173048
---
 mfbt/FloatingPoint.h             | 14 --------------
 mfbt/tests/TestFloatingPoint.cpp | 27 ++++++++++-----------------
 2 files changed, 10 insertions(+), 31 deletions(-)

diff --git a/mfbt/FloatingPoint.h b/mfbt/FloatingPoint.h
index 5f50d4910fc09..df418c8e0849d 100644
--- a/mfbt/FloatingPoint.h
+++ b/mfbt/FloatingPoint.h
@@ -155,20 +155,6 @@ struct FloatingPoint final : private detail::FloatingPointTrait<T> {
                 "all bits accounted for");
 };
 
-/** Determines whether a float/double is NaN. */
-template <typename T>
-static MOZ_ALWAYS_INLINE bool IsNaN(T aValue) {
-  /*
-   * A float/double is NaN if all exponent bits are 1 and the significand
-   * contains at least one non-zero bit.
-   */
-  typedef FloatingPoint<T> Traits;
-  typedef typename Traits::Bits Bits;
-  return (BitwiseCast<Bits>(aValue) & Traits::kExponentBits) ==
-             Traits::kExponentBits &&
-         (BitwiseCast<Bits>(aValue) & Traits::kSignificandBits) != 0;
-}
-
 /** Determines whether a float/double is +Infinity or -Infinity. */
 template <typename T>
 static MOZ_ALWAYS_INLINE bool IsInfinite(T aValue) {
diff --git a/mfbt/tests/TestFloatingPoint.cpp b/mfbt/tests/TestFloatingPoint.cpp
index 0379d71571262..7e1fd9e032803 100644
--- a/mfbt/tests/TestFloatingPoint.cpp
+++ b/mfbt/tests/TestFloatingPoint.cpp
@@ -16,7 +16,6 @@ using mozilla::FuzzyEqualsMultiplicative;
 using mozilla::IsFinite;
 using mozilla::IsFloat32Representable;
 using mozilla::IsInfinite;
-using mozilla::IsNaN;
 using mozilla::IsNegative;
 using mozilla::IsNegativeZero;
 using mozilla::IsPositiveZero;
@@ -310,15 +309,12 @@ static void TestEqualsIsForNonInteger(T aVal) {
 };
 
 static void TestDoublesPredicates() {
-  A(IsNaN(UnspecifiedNaN<double>()));
-  A(IsNaN(SpecificNaN<double>(1, 17)));
+  A(std::isnan(UnspecifiedNaN<double>()));
+  A(std::isnan(SpecificNaN<double>(1, 17)));
   ;
-  A(IsNaN(SpecificNaN<double>(0, 0xfffffffffff0fULL)));
-  A(!IsNaN(0.0));
-  A(!IsNaN(-0.0));
-  A(!IsNaN(1.0));
-  A(!IsNaN(PositiveInfinity<double>()));
-  A(!IsNaN(NegativeInfinity<double>()));
+  A(std::isnan(SpecificNaN<double>(0, 0xfffffffffff0fULL)));
+  A(!std::isnan(PositiveInfinity<double>()));
+  A(!std::isnan(NegativeInfinity<double>()));
 
   A(IsInfinite(PositiveInfinity<double>()));
   A(IsInfinite(NegativeInfinity<double>()));
@@ -412,15 +408,12 @@ static void TestDoublesPredicates() {
 }
 
 static void TestFloatsPredicates() {
-  A(IsNaN(UnspecifiedNaN<float>()));
-  A(IsNaN(SpecificNaN<float>(1, 17)));
+  A(std::isnan(UnspecifiedNaN<float>()));
+  A(std::isnan(SpecificNaN<float>(1, 17)));
   ;
-  A(IsNaN(SpecificNaN<float>(0, 0x7fff0fUL)));
-  A(!IsNaN(0.0f));
-  A(!IsNaN(-0.0f));
-  A(!IsNaN(1.0f));
-  A(!IsNaN(PositiveInfinity<float>()));
-  A(!IsNaN(NegativeInfinity<float>()));
+  A(std::isnan(SpecificNaN<float>(0, 0x7fff0fUL)));
+  A(!std::isnan(PositiveInfinity<float>()));
+  A(!std::isnan(NegativeInfinity<float>()));
 
   A(IsInfinite(PositiveInfinity<float>()));
   A(IsInfinite(NegativeInfinity<float>()));
-- 
GitLab