فهرست منبع

Improved IsPowerOfTwo(). Thanks to Y-way for initial PR.

Lasse Öörni 9 سال پیش
والد
کامیت
e7599463ba
3فایلهای تغییر یافته به همراه3 افزوده شده و 5 حذف شده
  1. 1 0
      Docs/Urho3D.dox
  2. 1 0
      README.md
  3. 1 5
      Source/Urho3D/Math/MathDefs.h

+ 1 - 0
Docs/Urho3D.dox

@@ -111,6 +111,7 @@ Urho3D development, contributions and bugfixes by:
 - OvermindDL1
 - OvermindDL1
 - Skrylar
 - Skrylar
 - TheComet93
 - TheComet93
+- Y-way
 - 1vanK
 - 1vanK
 - andmar1x
 - andmar1x
 - amadeus_osa
 - amadeus_osa

+ 1 - 0
README.md

@@ -63,6 +63,7 @@ Urho3D development, contributions and bugfixes by:
 - OvermindDL1
 - OvermindDL1
 - Skrylar
 - Skrylar
 - TheComet93
 - TheComet93
+- Y-way
 - 1vanK
 - 1vanK
 - andmar1x
 - andmar1x
 - amadeus_osa
 - amadeus_osa

+ 1 - 5
Source/Urho3D/Math/MathDefs.h

@@ -166,11 +166,7 @@ template <> inline float Atan2<float>(float y, float x) { return M_RADTODEG * at
 /// Check whether an unsigned integer is a power of two.
 /// Check whether an unsigned integer is a power of two.
 inline bool IsPowerOfTwo(unsigned value)
 inline bool IsPowerOfTwo(unsigned value)
 {
 {
-    if (!value)
-        return true;
-    while (!(value & 1))
-        value >>= 1;
-    return value == 1;
+    return !(value & (value - 1));
 }
 }
 
 
 /// Round up to next power of two.
 /// Round up to next power of two.