[vlc-devel] commit: Skins2: Move method bodies with inline tags to before where they' re needed. Drop const in favour of static on power() and instead of recursing(!) make it use powf(). (JP Dinger )

git version control git at videolan.org
Sat Dec 5 22:35:14 CET 2009


vlc | branch: master | JP Dinger <jpd at videolan.org> | Mon Nov 23 14:11:05 2009 +0100| [c288689c5aa3ff5bc9292646b7196d744df6e438] | committer: JP Dinger 

Skins2: Move method bodies with inline tags to before where they're needed. Drop const in favour of static on power() and instead of recursing(!) make it use powf().

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c288689c5aa3ff5bc9292646b7196d744df6e438
---

 modules/gui/skins2/utils/bezier.cpp |   32 +++++++++++++++++---------------
 modules/gui/skins2/utils/bezier.hpp |    2 +-
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/modules/gui/skins2/utils/bezier.cpp b/modules/gui/skins2/utils/bezier.cpp
index defccf0..ea4d8c3 100644
--- a/modules/gui/skins2/utils/bezier.cpp
+++ b/modules/gui/skins2/utils/bezier.cpp
@@ -194,6 +194,23 @@ int Bezier::findNearestPoint( int x, int y ) const
 }
 
 
+inline float Bezier::power( float x, int n )
+{
+#if 0
+    return n <= 0 ? 1 : x * power( x, n - 1 );
+#else
+    return powf( x, n );
+#endif
+}
+
+
+inline float Bezier::computeCoeff( int i, int n, float t ) const
+{
+    return (power( t, i ) * power( 1 - t, (n - i) ) *
+        (m_ft[n] / m_ft[i] / m_ft[n - i]));
+}
+
+
 void Bezier::computePoint( float t, int &x, int &y ) const
 {
     // See http://astronomy.swin.edu.au/~pbourke/curves/bezier/ for a simple
@@ -212,18 +229,3 @@ void Bezier::computePoint( float t, int &x, int &y ) const
     y = lrintf(yPos);
 }
 
-
-inline float Bezier::computeCoeff( int i, int n, float t ) const
-{
-    return (power( t, i ) * power( 1 - t, (n - i) ) *
-        (m_ft[n] / m_ft[i] / m_ft[n - i]));
-}
-
-
-inline float Bezier::power( float x, int n ) const
-{
-    if( n > 0 )
-        return x * power( x, n - 1);
-    else
-        return 1;
-}
diff --git a/modules/gui/skins2/utils/bezier.hpp b/modules/gui/skins2/utils/bezier.hpp
index b747477..6c3a9b4 100644
--- a/modules/gui/skins2/utils/bezier.hpp
+++ b/modules/gui/skins2/utils/bezier.hpp
@@ -98,7 +98,7 @@ private:
     /// Helper function to compute a coefficient of the curve
     inline float computeCoeff( int i, int n, float t ) const;
     /// x^n
-    inline float power( float x, int n ) const;
+    static inline float power( float x, int n );
 };
 
 




More information about the vlc-devel mailing list