From 09a2b2ed3189fe12483cbd673c24ceddc2c20f3f Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 27 Jul 2009 10:14:24 +0100 Subject: [PATCH] [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.) --- src/cairo-xlib-display.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c index 92e96bab5..d9ee90483 100644 --- a/src/cairo-xlib-display.c +++ b/src/cairo-xlib-display.c @@ -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) {