summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@hotmail.com>2010-07-20 12:26:27 +0000
committerSebastian Rasmussen <sebras@hotmail.com>2010-07-20 12:26:27 +0000
commit544fb8ec397bbc5ff847a764e4885144ed852575 (patch)
treed9440bd9e380201268bda206fe1a404e3a3b05a1
parent3e30988a03ac08b86925f3da803520ccff63831c (diff)
downloadmupdf-544fb8ec397bbc5ff847a764e4885144ed852575.tar.xz
Replace explicit comparisons with MIN/MAX/ABS macros.
-rw-r--r--apps/pdfclean.c2
-rw-r--r--draw/blendmodes.c26
-rw-r--r--draw/pathscan.c2
-rw-r--r--fitz/filt_predict.c6
4 files changed, 14 insertions, 22 deletions
diff --git a/apps/pdfclean.c b/apps/pdfclean.c
index f4cd5d5b..ab2ee4c8 100644
--- a/apps/pdfclean.c
+++ b/apps/pdfclean.c
@@ -228,7 +228,7 @@ static void removeduplicateobjs(void)
if (fz_objcmp(a, b))
continue;
- newnumlist[num] = num < other ? num : other;
+ newnumlist[num] = MIN(num, other);
break;
}
}
diff --git a/draw/blendmodes.c b/draw/blendmodes.c
index 3f80d4f9..0c8c7eec 100644
--- a/draw/blendmodes.c
+++ b/draw/blendmodes.c
@@ -134,15 +134,13 @@ fz_luminosity_rgb(int *rd, int *gd, int *bd, int rb, int gb, int bb, int rs, int
if (delta > 0)
{
int max;
- max = r > g ? r : g;
- max = b > max ? b : max;
+ max = MAX(r, MAX(g, b));
scale = ((255 - y) << 16) / (max - y);
}
else
{
int min;
- min = r < g ? r : g;
- min = b < min ? b : min;
+ min = MIN(r, MIN(g, b));
scale = (y << 16) / (y - min);
}
r = y + (((r - y) * scale + 0x8000) >> 16);
@@ -164,10 +162,8 @@ fz_saturation_rgb(int *rd, int *gd, int *bd, int rb, int gb, int bb, int rs, int
int scale;
int r, g, b;
- minb = rb < gb ? rb : gb;
- minb = minb < bb ? minb : bb;
- maxb = rb > gb ? rb : gb;
- maxb = maxb > bb ? maxb : bb;
+ minb = MIN(rb, MIN(gb, bb));
+ maxb = MAX(rb, MAX(gb, bb));
if (minb == maxb)
{
/* backdrop has zero saturation, avoid divide by 0 */
@@ -177,10 +173,8 @@ fz_saturation_rgb(int *rd, int *gd, int *bd, int rb, int gb, int bb, int rs, int
return;
}
- mins = rs < gs ? rs : gs;
- mins = mins < bs ? mins : bs;
- maxs = rs > gs ? rs : gs;
- maxs = maxs > bs ? maxs : bs;
+ mins = MIN(rs, MIN(gs, bs));
+ maxs = MAX(rs, MAX(gs, bs));
scale = ((maxs - mins) << 16) / (maxb - minb);
y = (rb * 77 + gb * 151 + bb * 28 + 0x80) >> 8;
@@ -193,10 +187,8 @@ fz_saturation_rgb(int *rd, int *gd, int *bd, int rb, int gb, int bb, int rs, int
int scalemin, scalemax;
int min, max;
- min = r < g ? r : g;
- min = min < b ? min : b;
- max = r > g ? r : g;
- max = max > b ? max : b;
+ min = MIN(r, MIN(g, b));
+ max = MAX(r, MAX(g, b));
if (min < 0)
scalemin = (y << 16) / (y - min);
@@ -208,7 +200,7 @@ fz_saturation_rgb(int *rd, int *gd, int *bd, int rb, int gb, int bb, int rs, int
else
scalemax = 0x10000;
- scale = scalemin < scalemax ? scalemin : scalemax;
+ scale = MIN(scalemin, scalemax);
r = y + (((r - y) * scale + 0x8000) >> 16);
g = y + (((g - y) * scale + 0x8000) >> 16);
b = y + (((b - y) * scale + 0x8000) >> 16);
diff --git a/draw/pathscan.c b/draw/pathscan.c
index a1e09852..e177d788 100644
--- a/draw/pathscan.c
+++ b/draw/pathscan.c
@@ -145,7 +145,7 @@ fz_insertgelraw(fz_gel *gel, int x0, int y0, int x1, int y1)
dy = y1 - y0;
dx = x1 - x0;
- width = dx < 0 ? -dx : dx;
+ width = ABS(dx);
edge->xdir = dx > 0 ? 1 : -1;
edge->ydir = winding;
diff --git a/fitz/filt_predict.c b/fitz/filt_predict.c
index 8653d35e..17242742 100644
--- a/fitz/filt_predict.c
+++ b/fitz/filt_predict.c
@@ -112,9 +112,9 @@ paeth(int a, int b, int c)
{
/* The definitions of ac and bc are correct, not a typo. */
int ac = b - c, bc = a - c, abcc = ac + bc;
- int pa = (ac < 0 ? -ac : ac);
- int pb = (bc < 0 ? -bc : bc);
- int pc = (abcc < 0 ? -abcc : abcc);
+ int pa = ABS(ac);
+ int pb = ABS(bc);
+ int pc = ABS(abcc);
return pa <= pb && pa <= pc ? a : pb <= pc ? b : c;
}