[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Wed Oct 26 17:08:08 CEST 2005


SVN commit 474493 by staikos:

shave off a few d2i and fabs() calls


 M  +38 -35    kstvcurve.cpp  


--- trunk/extragear/graphics/kst/kst/kstvcurve.cpp #474492:474493
@@ -564,7 +564,7 @@
   // monotonically rising: we can do a binary search
   // should be reasonably fast
   if (xIsRising()) {
-    int i_top = sampleCount()-1;
+    int i_top = sampleCount() - 1;
     int i_bot = 0;
 
     // don't pre-check for x outside of the curve since this is not
@@ -817,14 +817,12 @@
 #endif
     if (hasLines()) {
       QPointArray points(MAX_NUM_POLYLINES);
-      double lineWidth;
-      bool foundNan;
       int lastPlottedX = 0;
       int lastPlottedY = 0;
       int index = 0;
       int i0Start = i0;
 
-      lineWidth = (double)width;
+      double lineWidth = (double)width;
       p->setPen(QPen(color(), width, style));
 
 // optimize - isnan seems expensive, at least in gcc debug mode
@@ -868,7 +866,7 @@
         ++i_pt;
         rX = xv->interpolate(i_pt, NS);
         rY = yv->interpolate(i_pt, NS);
-        foundNan = false;
+        bool foundNan = false;
 
         // if necessary continue looking for the first valid point...
         while (i_pt < iN && (isnan(rX) || isnan(rY))) {
@@ -911,7 +909,9 @@
           last_y1 = Y1;
 
           if (!foundNan) {
-            if (d2i(X1) == d2i(X2)) {
+            int X1i = d2i(X1);
+            int X2i = d2i(X2);
+            if (X1i == X2i) {
               if (overlap) {
                 if (Y1 > maxY) {
                   maxY = Y1;
@@ -933,8 +933,7 @@
               if (overlap) {
                 if (X2 >= Lx && X2 <= Hx) {
                   if (maxY <= Hy && minY >= Ly) {
-                    int X2i   = d2i(X2);
-                    int Y2i   = d2i(Y2);
+                    int Y2i = d2i(Y2);
                     int maxYi = d2i(maxY);
                     int minYi = d2i(minY);
 
@@ -967,7 +966,7 @@
                       minY = Ly;
                     }
                     if (minY >= Ly && minY <= Hy && maxY >= Ly && maxY <= Hy) {
-                      p->drawLine(d2i(X2), d2i(minY), d2i(X2), d2i(maxY));
+                      p->drawLine(X2i, d2i(minY), X2i, d2i(maxY));
                     }
                   }
                 }
@@ -1293,13 +1292,13 @@
         rX = xv->interpolate(i_pt, NS);
         rY = yv->interpolate(i_pt, NS);
         if (errorSame) {
-          rEX = exv->interpolate(i_pt, NS);
+          rEX = fabs(exv->interpolate(i_pt, NS));
           if (_xLog) {
-            rX1 = logX(rX-fabs(rEX));
-            rX2 = logX(rX+fabs(rEX));
+            rX1 = logX(rX - rEX);
+            rX2 = logX(rX + rEX);
           } else {
-            rX1 = rX-fabs(rEX);
-            rX2 = rX+fabs(rEX);
+            rX1 = rX - rEX;
+            rX2 = rX + rEX;
           }
         } else if (exv && exmv) {
           double rEXHi = fabs(exv->interpolate(i_pt, NS));
@@ -1315,19 +1314,19 @@
           rEX = exv->interpolate(i_pt, NS);
           if (_xLog) {
             rX1 = logX(rX);
-            rX2 = logX(rX+fabs(rEX));
+            rX2 = logX(rX + fabs(rEX));
           } else {
             rX1 = rX;
-            rX2 = rX+fabs(rEX);
+            rX2 = rX + fabs(rEX);
           }
           do_low_flag = false;
         } else {
-          rEX = exmv->interpolate(i_pt, NS);
+          rEX = fabs(exmv->interpolate(i_pt, NS));
           if (_xLog) {
-            rX1 = logX(rX-fabs(rEX));
+            rX1 = logX(rX - rEX);
             rX2 = logX(rX);
           } else {
-            rX1 = rX-fabs(rEX);
+            rX1 = rX - rEX;
             rX2 = rX;
           }
           do_high_flag = false;
@@ -1351,14 +1350,16 @@
         }
 
         if (X1 >= Lx && X2 <= Hx && Y1 >= Ly && Y1 <= Hy) {
-          p->drawLine(d2i(X1), d2i(Y1), d2i(X2), d2i(Y1));
+          int X1i = d2i(X1);
+          int X2i = d2i(X2);
+          int Y1i = d2i(Y1);
+          int Y2i = d2i(Y2);
+          p->drawLine(X1i, Y1i, X2i, Y1i);
           if (do_low_flag) {
-            p->drawLine(d2i(X1), d2i(Y1) + Point.dim(p),
-                      d2i(X1), d2i(Y1) - Point.dim(p));
+            p->drawLine(X1i, Y1i + Point.dim(p), X1i, Y1i - Point.dim(p));
           }
           if (do_high_flag) {
-            p->drawLine(d2i(X2), d2i(Y1) + Point.dim(p),
-                      d2i(X2), d2i(Y1) - Point.dim(p));
+            p->drawLine(X2i, Y1i + Point.dim(p), X2i, Y1i - Point.dim(p));
           }
         }
       }
@@ -1402,22 +1403,22 @@
             rY2 = rY + rEYHi;
           }
         } else if (eyv) {
-          rEY = eyv->interpolate(i_pt, NS);
+          rEY = fabs(eyv->interpolate(i_pt, NS));
           if (_yLog) {
             rY1 = logY(rY);
-            rY2 = logY(rY+fabs(rEY));
+            rY2 = logY(rY + rEY);
           } else {
             rY1 = rY;
-            rY2 = rY+fabs(rEY);
+            rY2 = rY + rEY;
           }
           do_low_flag = false;
         } else {
-          rEY = eymv->interpolate(i_pt, NS);
+          rEY = fabs(eymv->interpolate(i_pt, NS));
           if (_yLog) {
-            rY1 = logY(rY-fabs(rEY));
+            rY1 = logY(rY - rEY);
             rY2 = logY(rY);
           } else {
-            rY1 = rY-fabs(rEY);
+            rY1 = rY - rEY;
             rY2 = rY;
           }
           do_high_flag = false;
@@ -1441,14 +1442,16 @@
         }
 
         if (X1 >= Lx && X1 <= Hx && Y1 >= Ly && Y2 <= Hy) {
-          p->drawLine(d2i(X1), d2i(Y1), d2i(X1), d2i(Y2));
+          int X1i = d2i(X1);
+          int X2i = d2i(X2);
+          int Y1i = d2i(Y1);
+          int Y2i = d2i(Y2);
+          p->drawLine(X1i, Y1i, X1i, Y2i);
           if (do_low_flag) {
-            p->drawLine(d2i(X1) + Point.dim(p), d2i(Y1),
-                        d2i(X1) - Point.dim(p), d2i(Y1));
+            p->drawLine(X1i + Point.dim(p), Y1i, X1i - Point.dim(p), Y1i);
           }
           if (do_high_flag) {
-            p->drawLine(d2i(X1) + Point.dim(p), d2i(Y2),
-                        d2i(X1) - Point.dim(p), d2i(Y2));
+            p->drawLine(X1i + Point.dim(p), Y2i, X1i - Point.dim(p), Y2i);
           }
         }
       }


More information about the Kst mailing list