[xlib] Fast-path the likely case of retrieving a known xrender_format

If we know the CPU can read pointers atomically, then we can simply peek
into the cached_xrender_formats to see if we already have a match, before
taking the mutex. (Acquiring the mutex here is a minor nuisance that
appears on the callgrind profiles.)
This commit is contained in:
Chris Wilson 2009-07-27 10:14:24 +01:00
parent efb3445ee1
commit 09a2b2ed31

View file

@ -514,6 +514,12 @@ _cairo_xlib_display_get_xrender_format (cairo_xlib_display_t *display,
{
XRenderPictFormat *xrender_format;
#if ! ATOMIC_OP_NEEDS_MEMORY_BARRIER
xrender_format = display->cached_xrender_formats[format];
if (likely (xrender_format != NULL))
return xrender_format;
#endif
CAIRO_MUTEX_LOCK (display->mutex);
xrender_format = display->cached_xrender_formats[format];
if (xrender_format == NULL) {