[cairo-commit] src/cairo-color.c

Chris Wilson ickle at kemper.freedesktop.org
Sat May 5 04:35:33 PDT 2007


 src/cairo-color.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletion(-)

New commits:
diff-tree d81907734e18fb9302e78eccb1e25a838223b726 (from 966a39396eb75d9d4ecc9997bb21d62fba176f78)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat May 5 12:33:29 2007 +0100

    [cairo-color] Only compare the shorts for equality.
    
    By only checking the premultiplied shorts inside the cairo_color_t we
    only have to compare at most 8 bytes instead of the full 24 bytes.

diff --git a/src/cairo-color.c b/src/cairo-color.c
index 257f8d2..50a9a1c 100644
--- a/src/cairo-color.c
+++ b/src/cairo-color.c
@@ -165,5 +165,8 @@ cairo_bool_t
 _cairo_color_equal (const cairo_color_t *color_a,
 	            const cairo_color_t *color_b)
 {
-    return memcmp (color_a, color_b, sizeof (cairo_color_t)) == 0;
+    return color_a->red_short   == color_b->red_short   &&
+           color_a->green_short == color_b->green_short &&
+           color_a->blue_short  == color_b->blue_short  &&
+           color_a->alpha_short == color_b->alpha_short;
 }


More information about the cairo-commit mailing list