From 6fdb7f129c8154e288ee40765fa63ffaeebaf8fd Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 30 Oct 2007 10:42:22 +0000 Subject: [PATCH] Simplify return value from cairo_path_fixed_get_current_point(). The only caller of cairo_path_fixed_get_current_point(), used the status return to determine whether or not the path had a current point (and did not propagate the error) - for which we had already removed the _cairo_error() markup. Now we reduce the boolean status return to a cairo_bool_t, with a net reduction in code. --- src/cairo-path-fixed.c | 11 ++++------- src/cairo.c | 13 +++++-------- src/cairoint.h | 2 +- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c index a92bcd679..6aaa2eef6 100644 --- a/src/cairo-path-fixed.c +++ b/src/cairo-path-fixed.c @@ -340,21 +340,18 @@ _cairo_path_fixed_close_path (cairo_path_fixed_t *path) return CAIRO_STATUS_SUCCESS; } -cairo_status_t +cairo_bool_t _cairo_path_fixed_get_current_point (cairo_path_fixed_t *path, cairo_fixed_t *x, cairo_fixed_t *y) { - if (! path->has_current_point) { - /* No need for _cairo_error() as the only caller, - * cairo_get_current_point(), expects and handles NO_CURRENT_POINT */ - return CAIRO_STATUS_NO_CURRENT_POINT; - } + if (! path->has_current_point) + return FALSE; *x = path->current_point.x; *y = path->current_point.y; - return CAIRO_STATUS_SUCCESS; + return TRUE; } static cairo_status_t diff --git a/src/cairo.c b/src/cairo.c index 73c2dc455..d5ee15c63 100644 --- a/src/cairo.c +++ b/src/cairo.c @@ -3166,20 +3166,17 @@ cairo_get_antialias (cairo_t *cr) void cairo_get_current_point (cairo_t *cr, double *x_ret, double *y_ret) { - cairo_status_t status = CAIRO_STATUS_NO_CURRENT_POINT; cairo_fixed_t x_fixed, y_fixed; double x, y; - if (cr->status == CAIRO_STATUS_SUCCESS) - status = _cairo_path_fixed_get_current_point (cr->path, - &x_fixed, &y_fixed); - if (status == CAIRO_STATUS_NO_CURRENT_POINT) { - x = 0.0; - y = 0.0; - } else { + if (cr->status == CAIRO_STATUS_SUCCESS && + _cairo_path_fixed_get_current_point (cr->path, &x_fixed, &y_fixed)) { x = _cairo_fixed_to_double (x_fixed); y = _cairo_fixed_to_double (y_fixed); _cairo_gstate_backend_to_user (cr->gstate, &x, &y); + } else { + x = 0.0; + y = 0.0; } if (x_ret) diff --git a/src/cairoint.h b/src/cairoint.h index 16e8a0892..225cb4bcd 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -1479,7 +1479,7 @@ _cairo_path_fixed_rel_curve_to (cairo_path_fixed_t *path, cairo_private cairo_status_t _cairo_path_fixed_close_path (cairo_path_fixed_t *path); -cairo_private cairo_status_t +cairo_private cairo_bool_t _cairo_path_fixed_get_current_point (cairo_path_fixed_t *path, cairo_fixed_t *x, cairo_fixed_t *y);