[Kstars-devel] KDE/kdeedu/kstars/kstars

Alexey Khudyakov alexey.skladnoy at gmail.com
Fri Nov 6 22:13:21 CET 2009


SVN commit 1045844 by khudyakov:

Remove radian caching from dms. It's not really sensible to
cache results of multiplication. It's better to save some space

CCMAIL: kstars-devel at kde.org

 M  +0 -14     dms.cpp  
 M  +7 -11     dms.h  


--- trunk/KDE/kdeedu/kstars/kstars/dms.cpp #1045843:1045844
@@ -27,14 +27,12 @@
 void dms::setD( const double &x ) {
     D = x;
     scDirty = true;
-    rDirty = true;
 }
 
 void dms::setD(const int &d, const int &m, const int &s, const int &ms) {
     D = (double)abs(d) + ((double)m + ((double)s + (double)ms/1000.)/60.)/60.;
     if (d<0) {D = -1.0*D;}
     scDirty = true;
-    rDirty = true;
 }
 
 void dms::setH( const double &x ) {
@@ -45,14 +43,11 @@
     D = 15.0*((double)abs(h) + ((double)m + ((double)s + (double)ms/1000.)/60.)/60.);
     if (h<0) {D = -1.0*D;}
     scDirty = true;
-    rDirty = true;
 }
 
 void dms::setRadians( const double &Rad ) {
     setD( Rad/DegToRad );
-    Radians = Rad;
     scDirty = true;
-    rDirty = true;
 }
 
 bool dms::setFromString( const QString &str, bool isDeg ) {
@@ -254,15 +249,6 @@
     cosa = Cos;
 }
 
-const double& dms::radians( void ) const {
-    if ( rDirty ) {
-        Radians = D*DegToRad;
-        rDirty = false;
-    }
-
-    return Radians;
-}
-
 const dms dms::reduce( void ) const {
     double a = D;
     while (a<0.0) {a += 360.0;}
--- trunk/KDE/kdeedu/kstars/kstars/dms.h #1045843:1045844
@@ -279,7 +279,7 @@
     	*@return the Sine of the angle.
     	*@sa cos()
     	*/
-    const double& sin( void ) const;
+    const double& sin() const;
 
     /**@short Compute the Angle's Cosine.
     	*
@@ -289,15 +289,12 @@
     	*@return the Cosine of the angle.
     	*@sa sin()
     	*/
-    const double& cos( void ) const;
+    const double& cos() const;
 
     /**@short Express the angle in radians.
-    	*The computed Radians value is stored internally.  On subsequent calls,
-    	*the stored value is returned directly (unless the angle's value has
-    	*changed).
-    	*@return the angle in radians (double)
-    	*/
-    const double& radians( void ) const;
+     * @return the angle in radians (double)
+     */
+    double radians() const { return D*DegToRad; }
 
     /**@short Set angle according to the argument, in radians.
     	*
@@ -310,7 +307,7 @@
     /**return the equivalent angle between 0 and 360 degrees.
     	*@warning does not change the value of the parent angle itself.
     	*/
-    const dms reduce( void ) const;
+    const dms reduce() const;
 
     /**@return a nicely-formatted string representation of the angle
     	*in degrees, arcminutes, and arcseconds.
@@ -351,9 +348,8 @@
 private:
     double D;
 
-    mutable double Radians;
     mutable double Sin, Cos;
-    mutable bool scDirty, rDirty;
+    mutable bool scDirty;
 };
 
 #endif


More information about the Kstars-devel mailing list