[cairo] [PATCH] Avoid appending an empty slot to an user data array when user_data is NULL.

Bryce Harrington bryce at osg.samsung.com
Mon Apr 20 17:18:59 PDT 2015


On Fri, Apr 17, 2015 at 04:33:35PM +0100, Chris Wilson wrote:
> On Fri, Apr 17, 2015 at 08:59:17PM +0900, 江頭幸路 wrote:
> >    Otherwise, calling cairo_set_user_data(cr, key, 0, 0) many times
> >    causes a long user data array, almost all of whose slots are empty.
> >    It leads to unnecessarily much memory consumption and long execution time
> >    of
> >    cairo_set_user_data(cr, key, 0, 0) and cairo_get_user_data(cr, key) after
> >    it.
> >    ---
> >     src/cairo-array.c |    3 +++
> >     1 file changed, 3 insertions(+)
> > 
> >    diff --git a/src/cairo-array.c b/src/cairo-array.c
> >    index 4f3c082..58c9a38 100644
> >    --- a/src/cairo-array.c
> >    +++ b/src/cairo-array.c
> >    @@ -485,6 +485,9 @@ _cairo_user_data_array_set_data
> >    (cairo_user_data_array_t     *array,
> >         return CAIRO_STATUS_SUCCESS;
> >         }
> >     
> >    +    if (user_data == NULL)
> >    +    return CAIRO_STATUS_SUCCESS;
> 
> Ok, I thought this might break a cairo_user_data_exists(), but since we
> don't have one, this patch lgtm and doesn't seem to change the API.
> -Chris

Thanks, applied:
   89942c6..040ae0c  master -> master

(I think something may have been off with the tabs or something, as it
didn't apply directly; since the patch was trivial enough I just
manually applied it.)

Bryce
 
> -- 
> Chris Wilson, Intel Open Source Technology Centre
> -- 
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo


More information about the cairo mailing list