瀏覽代碼

Merge pull request #104273 from Ivorforce/fabs-absf

Simplify and optimize `Math::absf` implementation to use `::fabs` and `::fabsf`.
Thaddeus Crews 5 月之前
父節點
當前提交
06f0c6369e
共有 1 個文件被更改,包括 2 次插入15 次删除
  1. 2 15
      core/math/math_funcs.h

+ 2 - 15
core/math/math_funcs.h

@@ -628,24 +628,11 @@ public:
 	}
 	}
 
 
 	static _ALWAYS_INLINE_ float absf(float g) {
 	static _ALWAYS_INLINE_ float absf(float g) {
-		union {
-			float f;
-			uint32_t i;
-		} u;
-
-		u.f = g;
-		u.i &= 2147483647u;
-		return u.f;
+		return ::fabsf(g);
 	}
 	}
 
 
 	static _ALWAYS_INLINE_ double absd(double g) {
 	static _ALWAYS_INLINE_ double absd(double g) {
-		union {
-			double d;
-			uint64_t i;
-		} u;
-		u.d = g;
-		u.i &= (uint64_t)9223372036854775807ll;
-		return u.d;
+		return ::fabs(g);
 	}
 	}
 
 
 	// This function should be as fast as possible and rounding mode should not matter.
 	// This function should be as fast as possible and rounding mode should not matter.