Revision: 55624
          http://sourceforge.net/p/brlcad/code/55624
Author:   brlcad
Date:     2013-06-01 03:25:26 +0000 (Sat, 01 Jun 2013)
Log Message:
-----------
main() isn't that complicated, doesn't benefit from the min/max scope

Modified Paths:
--------------
    brlcad/trunk/src/util/dpix-pix.c

Modified: brlcad/trunk/src/util/dpix-pix.c
===================================================================
--- brlcad/trunk/src/util/dpix-pix.c    2013-06-01 03:22:23 UTC (rev 55623)
+++ brlcad/trunk/src/util/dpix-pix.c    2013-06-01 03:25:26 UTC (rev 55624)
@@ -56,6 +56,8 @@
     double b;                  /* intercept */
     char *ifname;
 
+    double min, max;           /* high usage items */
+
     if (argc < 2) {
        bu_exit(1, "Usage: dpix-pix file.dpix > file.pix\n");
     }
@@ -72,46 +74,41 @@
        bu_exit(2, "dpix-pix:  binary output directed to terminal, aborting\n");
     }
 
-    {
-       double min, max;                /* high usage items */
+    min = INFINITY;
+    max = -INFINITY;
 
-       min = INFINITY;
-       max = -INFINITY;
-
-       while (1) {
-           got = read(fd, (char *)&doub[0], NUM*sizeof(doub[0]));
-           if (got <= 0) {
-               if (got < 0) {
-                   perror("dpix-pix READ ERROR");
-               }
-               break;
+    while (1) {
+       got = read(fd, (char *)&doub[0], NUM*sizeof(doub[0]));
+       if (got <= 0) {
+           if (got < 0) {
+               perror("dpix-pix READ ERROR");
            }
-           count = got / sizeof(doub[0]);
-           ep = &doub[count];
-           for (dp = &doub[0]; dp < ep;) {
-               double val = *dp++;
+           break;
+       }
+       count = got / sizeof(doub[0]);
+       ep = &doub[count];
+       for (dp = &doub[0]; dp < ep;) {
+           double val = *dp++;
 
-               V_MIN(min, val);
-               V_MAX(max, val);
-           }
+           V_MIN(min, val);
+           V_MAX(max, val);
        }
+    }
 
-       lseek(fd, 0, 0);                /* rewind(fp); */
+    lseek(fd, 0, 0);           /* rewind(fp); */
 
+    /* This section uses the maximum and the minimum values found to
+     * compute the m and the b of the line as specified by the
+     * equation y = mx + b.
+     */
+    fprintf(stderr, "min=%f, max=%f\n", min, max);
+    if (max < min) {
+       bu_exit(1, "MINMAX: max less than min!\n");
+    }
 
-       /* This section uses the maximum and the minimum values found to
-        * compute the m and the b of the line as specified by the
-        * equation y = mx + b.
-        */
-       fprintf(stderr, "min=%f, max=%f\n", min, max);
-       if (max < min) {
-           bu_exit(1, "MINMAX: max less than min!\n");
-       }
+    m = (255 - 0)/(max - min);
+    b = (-255 * min)/(max - min);
 
-       m = (255 - 0)/(max - min);
-       b = (-255 * min)/(max - min);
-    }
-
     while (1) {
        char *cp;               /* ptr to c */
        double mm;              /* slope */

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to