hook by ID optimisation for incoming 10k index size : 256 facilities * 10 events...
[lttv.git] / ltt / branches / poly / lttv / lttv / hook.h
index 502ac5c8732b4b337fd9f4b6db3e2492fd1e62b7..b62ddcfc8bded1e28796d471a19292dc5f9f9772 100644 (file)
@@ -22,6 +22,7 @@
 #define HOOK_H
 
 #include <glib.h>
+#include <ltt/compiler.h>
 
 /* A hook is a function to call with the supplied hook data, and with 
    call site specific data (e.g., hooks for events are called with a 
@@ -122,7 +123,10 @@ gboolean lttv_hooks_call_check_merge(LttvHooks *h1, void *call_data1,
 /* Sometimes different hooks need to be called based on the case. The
    case is represented by an unsigned integer id */
 
-typedef GPtrArray LttvHooksById;
+typedef struct _LttvHooksById {
+  GPtrArray *index;
+  GArray *array;
+} LttvHooksById;
 
 
 /* Create and destroy a hooks by id list */
@@ -144,10 +148,10 @@ unsigned lttv_hooks_by_id_max_id(LttvHooksById *h);
 
 /* Get the list of hooks for an id, NULL if none exists */
 
-inline LttvHooks *lttv_hooks_by_id_get(LttvHooksById *h, unsigned id)
+static inline LttvHooks *lttv_hooks_by_id_get(LttvHooksById *h, unsigned id)
 {
   LttvHooks *ret;
-  if(id < h->len) ret = h->pdata[id];
+  if(likely(id < h->index->len)) ret = h->index->pdata[id];
   else ret = NULL;
 
   return ret;
This page took 0.033284 seconds and 4 git commands to generate.