Revision: 55623
http://sourceforge.net/p/brlcad/code/55623
Author: brlcad
Date: 2013-06-01 03:22:23 +0000 (Sat, 01 Jun 2013)
Log Message:
-----------
vmath min/max macros ftw. also use a more standard definition of infinity and
eliminate those silly static globals.
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:15:37 UTC (rev 55622)
+++ brlcad/trunk/src/util/dpix-pix.c 2013-06-01 03:22:23 UTC (rev 55623)
@@ -34,17 +34,19 @@
#include <stdlib.h>
#include "bio.h"
+#include "vmath.h"
#include "bu.h"
#define NUM (1024 * 16) /* Note the powers of 2 -- v. efficient */
-static double doub[NUM];
-static unsigned char cha[NUM];
int
main(int argc, char **argv)
{
+ double doub[NUM];
+ unsigned char cha[NUM];
+
size_t count; /* count of items */
ssize_t got; /* count of bytes */
int fd; /* UNIX file descriptor */
@@ -70,17 +72,11 @@
bu_exit(2, "dpix-pix: binary output directed to terminal, aborting\n");
}
- /* Note that the minimum is set to 1.0e20, the computer's working
- * equivalent of positive infinity. Thus any subsequent value
- * must be smaller than it. Likewise, the maximum is set to -1.0e20,
- * the equivalent of negative infinity, and any subsequent values
- * must thus be bigger than it.
- */
{
double min, max; /* high usage items */
- min = 1.0e20;
- max = -1.0e20;
+ min = INFINITY;
+ max = -INFINITY;
while (1) {
got = read(fd, (char *)&doub[0], NUM*sizeof(doub[0]));
@@ -93,11 +89,10 @@
count = got / sizeof(doub[0]);
ep = &doub[count];
for (dp = &doub[0]; dp < ep;) {
- double val;
- if ((val = *dp++) < min)
- min = val;
- else if (val > max)
- max = val;
+ double val = *dp++;
+
+ V_MIN(min, val);
+ V_MAX(max, val);
}
}
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