[PATCH] dix: optimize CallCallbacks

Adam Jackson ajax at redhat.com
Mon Oct 11 13:37:16 PDT 2010


Move the basic sanity checking to an inline wrapper, which avoids the
function call overhead if the callback list is empty.  On an XACEful
server on a 2.4GHz Core 2 Duo:

    1              2           Operation
--------   -----------------   -----------------
20000000.0   25100000.0 (  1.25)   X protocol NoOperation

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 dix/dixutils.c     |    9 +--------
 include/callback.h |    9 ++++++++-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/dix/dixutils.c b/dix/dixutils.c
index 470bb5d..104363b 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -729,7 +729,7 @@ _DeleteCallback(
     return FALSE;
 }
 
-static void 
+void 
 _CallCallbacks(
     CallbackListPtr    *pcbl,
     pointer	    call_data)
@@ -871,13 +871,6 @@ DeleteCallback(CallbackListPtr *pcbl, CallbackProcPtr callback, pointer data)
 }
 
 void
-CallCallbacks(CallbackListPtr *pcbl, pointer call_data)
-{
-    if (!pcbl || !*pcbl) return;
-    _CallCallbacks(pcbl, call_data);
-}
-
-void
 DeleteCallbackList(CallbackListPtr *pcbl)
 {
     if (!pcbl || !*pcbl) return;
diff --git a/include/callback.h b/include/callback.h
index 632ed4f..9a1da73 100644
--- a/include/callback.h
+++ b/include/callback.h
@@ -75,10 +75,17 @@ extern _X_EXPORT Bool DeleteCallback(
     CallbackProcPtr /*callback*/,
     pointer /*data*/);
 
-extern _X_EXPORT void CallCallbacks(
+extern _X_EXPORT void _CallCallbacks(
     CallbackListPtr * /*pcbl*/,
     pointer /*call_data*/);
 
+static inline void
+CallCallbacks(CallbackListPtr *pcbl, pointer call_data)
+{
+    if (!pcbl || !*pcbl) return;
+    _CallCallbacks(pcbl, call_data);
+}
+
 extern _X_EXPORT void DeleteCallbackList(
     CallbackListPtr * /*pcbl*/);
 
-- 
1.7.3.1



More information about the xorg-devel mailing list