summaryrefslogtreecommitdiff
path: root/src/cairo-bentley-ottmann.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-10-05 10:15:49 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2008-10-06 12:07:41 +0100
commit76dd4603d01068b1b377312ced6b44fe5419794f (patch)
tree1b7bf8fb229e46a30c6ff74ae45871b66d8f62cf /src/cairo-bentley-ottmann.c
parent6eead4a5f746e182eabfcda9959cd9cc53d95a89 (diff)
downloadcairo-76dd4603d01068b1b377312ced6b44fe5419794f.tar.gz
[tessellator] Replace open-coding _cairo_int64_cmp().
We often use the construct: if (_cairo_int64_lt (A, B) return -1; if (_cairo_int64_gt (A, B) return 1; return 0; to compare two large integers (int64, or int128) which does twice the required work on CPUs without large integer support. So replace it with a single wideint function _cairo_int64_cmp() and therefore allow opportunities to both shrink the code size and write a more efficient comparison. (The primarily motivation is to simply replace each block with a single more expressive line.)
Diffstat (limited to 'src/cairo-bentley-ottmann.c')
-rw-r--r--src/cairo-bentley-ottmann.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/src/cairo-bentley-ottmann.c b/src/cairo-bentley-ottmann.c
index 28952ddad..47ee83387 100644
--- a/src/cairo-bentley-ottmann.c
+++ b/src/cairo-bentley-ottmann.c
@@ -201,21 +201,13 @@ _slope_compare (cairo_bo_edge_t *a,
* with respect to x. */
if ((adx ^ bdx) < 0) {
return adx < 0 ? -1 : +1;
- }
- else {
+ } else {
int32_t ady = a->bottom.y - a->top.y;
int32_t bdy = b->bottom.y - b->top.y;
int64_t adx_bdy = _cairo_int32x32_64_mul (adx, bdy);
int64_t bdx_ady = _cairo_int32x32_64_mul (bdx, ady);
- /* if (adx * bdy > bdx * ady) */
- if (_cairo_int64_gt (adx_bdy, bdx_ady))
- return 1;
-
- /* if (adx * bdy < bdx * ady) */
- if (_cairo_int64_lt (adx_bdy, bdx_ady))
- return -1;
- return 0;
+ return _cairo_int64_cmp (adx_bdy, bdx_ady);
}
}
@@ -320,12 +312,7 @@ edge_compare_for_y_against_x (const cairo_bo_edge_t *a,
L = _cairo_int32x32_64_mul (dy, adx);
R = _cairo_int32x32_64_mul (dx, ady);
- /* return _cairo_int64_cmp (L, R); */
- if (_cairo_int64_lt (L, R))
- return -1;
- if (_cairo_int64_gt (L, R))
- return 1;
- return 0;
+ return _cairo_int64_cmp (L, R);
}
static int